Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
ae3cf693
Commit
ae3cf693
authored
Nov 30, 2016
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mobile scroll refactoring
parent
945bddca
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2329 additions
and
4416 deletions
+2329
-4416
build/configs/webexcel.json
build/configs/webexcel.json
+2
-2
cell/view/iscroll.js
cell/view/iscroll.js
+0
-1236
cell/view/mobileTouch.js
cell/view/mobileTouch.js
+244
-2073
common/Drawings/WorkEvents.js
common/Drawings/WorkEvents.js
+84
-26
common/Scrolls/iscroll.js
common/Scrolls/iscroll.js
+1966
-1079
word/Drawing/HtmlPage.js
word/Drawing/HtmlPage.js
+33
-0
No files found.
build/configs/webexcel.json
View file @
ae3cf693
...
@@ -82,7 +82,7 @@
...
@@ -82,7 +82,7 @@
"../common/Drawings/HatchPattern.js"
,
"../common/Drawings/HatchPattern.js"
,
"../common/scroll.js"
,
"../common/scroll.js"
,
"../c
ell/view
/iscroll.js"
,
"../c
ommon/Scrolls
/iscroll.js"
,
"../common/wordcopypaste.js"
,
"../common/wordcopypaste.js"
,
...
@@ -249,7 +249,7 @@
...
@@ -249,7 +249,7 @@
"../common/FontsFreeType/TextMeasurer.js"
,
"../common/FontsFreeType/TextMeasurer.js"
,
"../cell/model/DrawingObjects/Graphics.js"
,
"../cell/model/DrawingObjects/Graphics.js"
,
"../common/Drawings/TextDrawer.js"
,
"../common/Drawings/TextDrawer.js"
,
"../c
ell/view/iscroll.js"
"../c
ommon/Scrolls/iscroll.js"
,
],
],
"dst"
:
"../cell"
,
"dst"
:
"../cell"
,
"externs"
:
[
"externs"
:
[
...
...
cell/view/iscroll.js
deleted
100644 → 0
View file @
945bddca
/*!
* iScroll v4.2.5 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
* Released under MIT license, http://cubiq.org/license
*/
(
function
(
window
,
doc
)
{
var
m
=
Math
,
dummyStyle
=
doc
.
createElement
(
'
div
'
).
style
,
vendor
=
(
function
()
{
var
vendors
=
'
t,webkitT,MozT,msT,OT
'
.
split
(
'
,
'
),
t
,
i
=
0
,
l
=
vendors
.
length
;
for
(
;
i
<
l
;
i
++
)
{
t
=
vendors
[
i
]
+
'
ransform
'
;
if
(
t
in
dummyStyle
)
{
return
vendors
[
i
].
substr
(
0
,
vendors
[
i
].
length
-
1
);
}
}
return
false
;
})(),
cssVendor
=
vendor
?
'
-
'
+
vendor
.
toLowerCase
()
+
'
-
'
:
''
,
// Style properties
transform
=
prefixStyle
(
'
transform
'
),
transitionProperty
=
prefixStyle
(
'
transitionProperty
'
),
transitionDuration
=
prefixStyle
(
'
transitionDuration
'
),
transformOrigin
=
prefixStyle
(
'
transformOrigin
'
),
transitionTimingFunction
=
prefixStyle
(
'
transitionTimingFunction
'
),
transitionDelay
=
prefixStyle
(
'
transitionDelay
'
),
// Browser capabilities
isAndroid
=
(
/android/gi
).
test
(
navigator
.
appVersion
),
isIDevice
=
(
/iphone|ipad/gi
).
test
(
navigator
.
appVersion
),
isTouchPad
=
(
/hp-tablet/gi
).
test
(
navigator
.
appVersion
),
has3d
=
prefixStyle
(
'
perspective
'
)
in
dummyStyle
,
hasTouch
=
'
ontouchstart
'
in
window
&&
!
isTouchPad
,
hasTransform
=
vendor
!==
false
,
hasTransitionEnd
=
prefixStyle
(
'
transition
'
)
in
dummyStyle
,
TRNEND_EV
=
(
function
()
{
if
(
vendor
===
false
)
return
false
;
var
transitionEnd
=
{
''
:
'
transitionend
'
,
'
webkit
'
:
'
webkitTransitionEnd
'
,
'
Moz
'
:
'
transitionend
'
,
'
O
'
:
'
otransitionend
'
,
'
ms
'
:
'
MSTransitionEnd
'
};
return
transitionEnd
[
vendor
];
})(),
nextFrame
=
(
function
()
{
return
window
.
requestAnimationFrame
||
window
.
webkitRequestAnimationFrame
||
window
.
mozRequestAnimationFrame
||
window
.
oRequestAnimationFrame
||
window
.
msRequestAnimationFrame
||
function
(
callback
)
{
return
setTimeout
(
callback
,
1
);
};
})(),
cancelFrame
=
(
function
()
{
return
window
.
cancelRequestAnimationFrame
||
window
.
webkitCancelAnimationFrame
||
window
.
webkitCancelRequestAnimationFrame
||
window
.
mozCancelRequestAnimationFrame
||
window
.
oCancelRequestAnimationFrame
||
window
.
msCancelRequestAnimationFrame
||
clearTimeout
;
})(),
// Helpers
translateZ
=
has3d
?
'
translateZ(0)
'
:
''
,
// Constructor
CTouchScroll
=
function
(
api
,
options
,
scroller
)
{
var
that
=
this
,
i
;
that
.
api
=
api
;
that
.
wrapper
=
api
.
element
;
that
.
wrapper
.
style
.
overflow
=
'
hidden
'
;
that
.
scroller
=
(
scroller
!==
undefined
)
?
scroller
:
null
;
// Default options
that
.
options
=
{
hScroll
:
true
,
vScroll
:
true
,
x
:
0
,
y
:
0
,
bounce
:
false
,
bounceLock
:
false
,
momentum
:
true
,
lockDirection
:
true
,
useTransform
:
true
,
useTransition
:
false
,
topOffset
:
0
,
checkDOMChanges
:
false
,
// Experimental
handleClick
:
true
,
// Scrollbar
hScrollbar
:
true
,
vScrollbar
:
true
,
fixedScrollbar
:
isAndroid
,
hideScrollbar
:
/*isIDevice*/
true
,
fadeScrollbar
:
isIDevice
&&
has3d
,
scrollbarClass
:
''
,
// Zoom
zoom
:
false
,
zoomMin
:
1
,
zoomMax
:
4
,
doubleTapZoom
:
2
,
wheelAction
:
'
scroll
'
,
// Snap
snap
:
false
,
snapThreshold
:
1
,
// Events
onRefresh
:
null
,
onBeforeScrollStart
:
null
,
onScrollStart
:
null
,
onBeforeScrollMove
:
null
,
onScrollMove
:
null
,
onBeforeScrollEnd
:
null
,
onScrollEnd
:
null
,
onTouchEnd
:
null
,
onDestroy
:
null
,
onZoomStart
:
null
,
onZoom
:
null
,
onZoomEnd
:
null
};
// User defined options
for
(
i
in
options
)
that
.
options
[
i
]
=
options
[
i
];
// Set starting position
that
.
x
=
that
.
options
.
x
;
that
.
y
=
that
.
options
.
y
;
// Normalize options
that
.
options
.
useTransform
=
hasTransform
&&
that
.
options
.
useTransform
;
that
.
options
.
hScrollbar
=
that
.
options
.
hScroll
&&
that
.
options
.
hScrollbar
;
that
.
options
.
vScrollbar
=
that
.
options
.
vScroll
&&
that
.
options
.
vScrollbar
;
that
.
options
.
zoom
=
that
.
options
.
useTransform
&&
that
.
options
.
zoom
;
that
.
options
.
useTransition
=
hasTransitionEnd
&&
that
.
options
.
useTransition
;
// Helpers FIX ANDROID BUG!
// translate3d and scale doesn't work together!
// Ignoring 3d ONLY WHEN YOU SET that.options.zoom
if
(
that
.
options
.
zoom
&&
isAndroid
)
{
translateZ
=
''
;
}
// Set some default styles
if
(
that
.
scroller
)
{
that
.
scroller
.
style
[
transitionProperty
]
=
that
.
options
.
useTransform
?
cssVendor
+
'
transform
'
:
'
top left
'
;
that
.
scroller
.
style
[
transitionDuration
]
=
'
0
'
;
that
.
scroller
.
style
[
transformOrigin
]
=
'
0 0
'
;
if
(
that
.
options
.
useTransition
)
that
.
scroller
.
style
[
transitionTimingFunction
]
=
'
cubic-bezier(0.33,0.66,0.66,1)
'
;
if
(
that
.
options
.
useTransform
)
that
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
that
.
x
+
'
px,
'
+
that
.
y
+
'
px)
'
+
translateZ
;
else
that
.
scroller
.
style
.
cssText
+=
'
;position:absolute;top:
'
+
that
.
y
+
'
px;left:
'
+
that
.
x
+
'
px
'
;
}
if
(
that
.
options
.
useTransition
)
that
.
options
.
fixedScrollbar
=
true
;
that
.
refresh
();
};
// Prototype
CTouchScroll
.
prototype
=
{
enabled
:
true
,
x
:
0
,
y
:
0
,
steps
:[],
scale
:
1
,
currPageX
:
0
,
currPageY
:
0
,
pagesX
:[],
pagesY
:[],
aniTime
:
null
,
wheelZoomCount
:
0
,
handleEvent
:
function
(
e
)
{
var
that
=
this
;
switch
(
e
.
type
)
{
case
TRNEND_EV
:
that
.
_transitionEnd
(
e
);
break
;
}
},
_scrollbar
:
function
(
dir
)
{
var
that
=
this
,
bar
;
if
(
dir
==
'
h
'
)
{
if
(
!
that
.
hScrollbar
)
{
if
(
that
.
hScrollbarWrapper
)
{
if
(
hasTransform
)
that
.
hScrollbarIndicator
.
style
[
transform
]
=
''
;
that
.
hScrollbarWrapper
.
parentNode
.
removeChild
(
that
.
hScrollbarWrapper
);
that
.
hScrollbarWrapper
=
null
;
that
.
hScrollbarIndicator
=
null
;
}
return
;
}
if
(
!
that
.
hScrollbarWrapper
)
{
// Create the scrollbar wrapper
bar
=
doc
.
createElement
(
'
div
'
);
if
(
that
.
options
.
scrollbarClass
)
bar
.
className
=
that
.
options
.
scrollbarClass
+
dir
.
toUpperCase
();
else
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;height:7px;bottom:1px;left:2px;right:
'
+
(
that
.
vScrollbar
?
'
7
'
:
'
2
'
)
+
'
px
'
;
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:opacity;
'
+
cssVendor
+
'
transition-duration:
'
+
(
that
.
options
.
fadeScrollbar
?
'
350ms
'
:
'
0
'
)
+
'
;overflow:hidden;opacity:
'
+
(
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
);
that
.
wrapper
.
appendChild
(
bar
);
that
.
hScrollbarWrapper
=
bar
;
// Create the scrollbar indicator
bar
=
doc
.
createElement
(
'
div
'
);
if
(
!
that
.
options
.
scrollbarClass
)
{
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);
'
+
cssVendor
+
'
background-clip:padding-box;
'
+
cssVendor
+
'
box-sizing:border-box;height:100%;
'
+
cssVendor
+
'
border-radius:3px;border-radius:3px
'
;
}
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:
'
+
cssVendor
+
'
transform;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);
'
+
cssVendor
+
'
transition-duration:0;
'
+
cssVendor
+
'
transform: translate(0,0)
'
+
translateZ
;
if
(
that
.
options
.
useTransition
)
bar
.
style
.
cssText
+=
'
;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)
'
;
that
.
hScrollbarWrapper
.
appendChild
(
bar
);
that
.
hScrollbarIndicator
=
bar
;
}
var
percentInViewH
;
that
.
hScrollbarSize
=
that
.
hScrollbarWrapper
.
clientWidth
;
percentInViewH
=
(
Math
.
abs
(
that
.
maxScrollX
)
+
that
.
hScrollbarSize
)
/
that
.
hScrollbarSize
;
that
.
hScrollbarIndicatorSize
=
m
.
min
(
that
.
hScrollbarSize
,
m
.
max
(
Math
.
ceil
(
1
/
percentInViewH
*
that
.
hScrollbarSize
),
8
)
);
that
.
hScrollbarIndicator
.
style
.
width
=
that
.
hScrollbarIndicatorSize
+
'
px
'
;
that
.
hScrollbarMaxScroll
=
that
.
hScrollbarSize
-
that
.
hScrollbarIndicatorSize
;
that
.
hScrollbarProp
=
that
.
hScrollbarMaxScroll
/
that
.
maxScrollX
;
// Reset position
that
.
_scrollbarPos
(
dir
,
true
);
}
else
if
(
dir
==
'
v
'
)
{
if
(
!
that
.
vScrollbar
)
{
if
(
that
.
vScrollbarWrapper
)
{
if
(
hasTransform
)
that
.
vScrollbarIndicator
.
style
[
transform
]
=
''
;
that
.
vScrollbarWrapper
.
parentNode
.
removeChild
(
that
.
vScrollbarWrapper
);
that
.
vScrollbarWrapper
=
null
;
that
.
vScrollbarIndicator
=
null
;
}
return
;
}
if
(
!
that
.
vScrollbarWrapper
)
{
// Create the scrollbar wrapper
bar
=
doc
.
createElement
(
'
div
'
);
if
(
that
.
options
.
scrollbarClass
)
bar
.
className
=
that
.
options
.
scrollbarClass
+
dir
.
toUpperCase
();
else
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;width:7px;bottom:
'
+
(
that
.
hScrollbar
?
'
7
'
:
'
2
'
)
+
'
px;top:2px;right:1px
'
;
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:opacity;
'
+
cssVendor
+
'
transition-duration:
'
+
(
that
.
options
.
fadeScrollbar
?
'
350ms
'
:
'
0
'
)
+
'
;overflow:hidden;opacity:
'
+
(
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
);
that
.
wrapper
.
appendChild
(
bar
);
that
.
vScrollbarWrapper
=
bar
;
// Create the scrollbar indicator
bar
=
doc
.
createElement
(
'
div
'
);
if
(
!
that
.
options
.
scrollbarClass
)
{
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);
'
+
cssVendor
+
'
background-clip:padding-box;
'
+
cssVendor
+
'
box-sizing:border-box;width:100%;
'
+
cssVendor
+
'
border-radius:3px;border-radius:3px
'
;
}
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:
'
+
cssVendor
+
'
transform;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);
'
+
cssVendor
+
'
transition-duration:0;
'
+
cssVendor
+
'
transform: translate(0,0)
'
+
translateZ
;
if
(
that
.
options
.
useTransition
)
bar
.
style
.
cssText
+=
'
;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)
'
;
that
.
vScrollbarWrapper
.
appendChild
(
bar
);
that
.
vScrollbarIndicator
=
bar
;
}
var
percentInViewW
;
that
.
vScrollbarSize
=
that
.
vScrollbarWrapper
.
clientHeight
;
percentInViewW
=
(
Math
.
abs
(
that
.
maxScrollY
)
+
that
.
vScrollbarSize
)
/
that
.
vScrollbarSize
;
that
.
vScrollbarIndicatorSize
=
m
.
min
(
that
.
vScrollbarSize
,
m
.
max
(
Math
.
ceil
(
1
/
percentInViewW
*
that
.
vScrollbarSize
),
8
)
);
that
.
vScrollbarIndicator
.
style
.
height
=
that
.
vScrollbarIndicatorSize
+
'
px
'
;
that
.
vScrollbarMaxScroll
=
that
.
vScrollbarSize
-
that
.
vScrollbarIndicatorSize
;
that
.
vScrollbarProp
=
that
.
vScrollbarMaxScroll
/
that
.
maxScrollY
;
// Reset position
that
.
_scrollbarPos
(
dir
,
true
);
}
},
_resize
:
function
()
{
var
that
=
this
;
setTimeout
(
function
()
{
that
.
refresh
();
},
isAndroid
?
200
:
0
);
},
_pos
:
function
(
x
,
y
,
isAnim
)
{
if
(
this
.
zoomed
)
return
;
x
=
this
.
hScroll
?
x
:
0
;
y
=
this
.
vScroll
?
y
:
0
;
this
.
x
=
x
;
this
.
y
=
y
;
if
(
isAnim
===
true
)
{
this
.
api
.
NoneRepaintPages
=
true
;
}
else
{
this
.
api
.
NoneRepaintPages
=
false
;
}
if
(
this
.
api
.
ReaderModeDiv
==
null
)
{
if
(
this
.
hScroll
)
{
this
.
api
.
_onScrollX
(
-
this
.
x
/
this
.
api
.
controller
.
settings
.
vscrollStep
);
}
if
(
this
.
vScroll
)
{
this
.
api
.
_onScrollY
(
-
this
.
y
/
this
.
api
.
controller
.
settings
.
hscrollStep
);
}
}
else
if
(
this
.
scroller
)
{
if
(
this
.
options
.
useTransform
)
{
this
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
x
+
'
px,
'
+
y
+
'
px) scale(
'
+
this
.
scale
+
'
)
'
+
translateZ
;
}
else
{
x
=
m
.
round
(
x
);
y
=
m
.
round
(
y
);
this
.
scroller
.
style
.
left
=
x
+
'
px
'
;
this
.
scroller
.
style
.
top
=
y
+
'
px
'
;
}
}
this
.
_scrollbarPos
(
'
h
'
);
this
.
_scrollbarPos
(
'
v
'
);
},
_scrollbarPos
:
function
(
dir
,
hidden
)
{
var
that
=
this
;
var
size
=
0
;
var
pos
=
that
.
y
;
if
(
dir
==
'
h
'
)
{
pos
=
that
.
x
;
if
(
!
that
.
hScrollbar
)
return
;
pos
=
that
.
hScrollbarProp
*
pos
;
if
(
pos
<
0
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
hScrollbarIndicatorSize
+
m
.
round
(
pos
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
hScrollbarIndicator
.
style
[
'
width
'
]
=
size
+
'
px
'
;
}
pos
=
0
;
}
else
if
(
pos
>
that
.
hScrollbarMaxScroll
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
hScrollbarIndicatorSize
-
m
.
round
(
(
pos
-
that
.
hScrollbarMaxScroll
)
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
hScrollbarIndicator
.
style
[
'
width
'
]
=
size
+
'
px
'
;
pos
=
that
.
hScrollbarMaxScroll
+
(
that
.
hScrollbarIndicatorSize
-
size
);
}
else
{
pos
=
that
.
hScrollbarMaxScroll
;
}
}
that
.
hScrollbarWrapper
.
style
[
transitionDelay
]
=
'
0
'
;
that
.
hScrollbarWrapper
.
style
.
opacity
=
hidden
&&
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
;
that
.
hScrollbarIndicator
.
style
[
transform
]
=
'
translate(
'
+
pos
+
'
px,0)
'
+
translateZ
;
}
else
{
if
(
!
that
.
vScrollbar
)
return
;
pos
=
that
.
vScrollbarProp
*
pos
;
if
(
pos
<
0
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
vScrollbarIndicatorSize
+
m
.
round
(
pos
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
vScrollbarIndicator
.
style
[
'
height
'
]
=
size
+
'
px
'
;
}
pos
=
0
;
}
else
if
(
pos
>
that
.
vScrollbarMaxScroll
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
vScrollbarIndicatorSize
-
m
.
round
(
(
pos
-
that
.
vScrollbarMaxScroll
)
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
vScrollbarIndicator
.
style
[
'
height
'
]
=
size
+
'
px
'
;
pos
=
that
.
vScrollbarMaxScroll
+
(
that
.
vScrollbarIndicatorSize
-
size
);
}
else
{
pos
=
that
.
vScrollbarMaxScroll
;
}
}
that
.
vScrollbarWrapper
.
style
[
transitionDelay
]
=
'
0
'
;
that
.
vScrollbarWrapper
.
style
.
opacity
=
hidden
&&
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
;
that
.
vScrollbarIndicator
.
style
[
transform
]
=
'
translate(0,
'
+
pos
+
'
px)
'
+
translateZ
;
}
},
_start
:
function
(
e
)
{
var
that
=
this
,
point
=
hasTouch
?
e
.
touches
[
0
]
:
e
,
matrix
,
x
,
y
,
c1
,
c2
;
if
(
!
that
.
enabled
)
return
;
if
(
that
.
options
.
onBeforeScrollStart
)
that
.
options
.
onBeforeScrollStart
.
call
(
that
,
e
);
if
(
that
.
options
.
useTransition
||
that
.
options
.
zoom
)
that
.
_transitionTime
(
0
);
that
.
moved
=
false
;
that
.
animating
=
false
;
that
.
zoomed
=
false
;
that
.
distX
=
0
;
that
.
distY
=
0
;
that
.
absDistX
=
0
;
that
.
absDistY
=
0
;
that
.
dirX
=
0
;
that
.
dirY
=
0
;
// Gesture start
if
(
that
.
options
.
zoom
&&
hasTouch
&&
e
.
touches
.
length
>
1
)
{
c1
=
m
.
abs
(
e
.
touches
[
0
].
pageX
-
e
.
touches
[
1
].
pageX
);
c2
=
m
.
abs
(
e
.
touches
[
0
].
pageY
-
e
.
touches
[
1
].
pageY
);
that
.
touchesDistStart
=
m
.
sqrt
(
c1
*
c1
+
c2
*
c2
);
that
.
originX
=
m
.
abs
(
e
.
touches
[
0
].
pageX
+
e
.
touches
[
1
].
pageX
-
that
.
wrapperOffsetLeft
*
2
)
/
2
-
that
.
x
;
that
.
originY
=
m
.
abs
(
e
.
touches
[
0
].
pageY
+
e
.
touches
[
1
].
pageY
-
that
.
wrapperOffsetTop
*
2
)
/
2
-
that
.
y
;
if
(
that
.
options
.
onZoomStart
)
that
.
options
.
onZoomStart
.
call
(
that
,
e
);
}
if
(
that
.
options
.
momentum
)
{
cancelFrame
(
that
.
aniTime
);
that
.
steps
=
[];
that
.
_pos
(
this
.
x
,
this
.
y
);
// это чтобы обновился экран
if
(
that
.
options
.
onScrollEnd
)
that
.
options
.
onScrollEnd
.
call
(
that
);
}
that
.
absStartX
=
that
.
x
;
// Needed by snap threshold
that
.
absStartY
=
that
.
y
;
that
.
startX
=
that
.
x
;
that
.
startY
=
that
.
y
;
that
.
pointX
=
point
.
pageX
;
that
.
pointY
=
point
.
pageY
;
that
.
startTime
=
e
.
timeStamp
||
Date
.
now
();
if
(
that
.
options
.
onScrollStart
)
that
.
options
.
onScrollStart
.
call
(
that
,
e
);
},
_move
:
function
(
e
)
{
var
that
=
this
,
point
=
hasTouch
?
e
.
touches
[
0
]
:
e
,
deltaX
=
point
.
pageX
-
that
.
pointX
,
deltaY
=
point
.
pageY
-
that
.
pointY
,
newX
=
that
.
x
+
deltaX
,
newY
=
that
.
y
+
deltaY
,
c1
,
c2
,
scale
,
timestamp
=
e
.
timeStamp
||
Date
.
now
();
if
(
that
.
options
.
onBeforeScrollMove
)
that
.
options
.
onBeforeScrollMove
.
call
(
that
,
e
);
// Zoom
if
(
that
.
options
.
zoom
&&
hasTouch
&&
e
.
touches
.
length
>
1
&&
that
.
scroller
)
{
c1
=
m
.
abs
(
e
.
touches
[
0
].
pageX
-
e
.
touches
[
1
].
pageX
);
c2
=
m
.
abs
(
e
.
touches
[
0
].
pageY
-
e
.
touches
[
1
].
pageY
);
that
.
touchesDist
=
m
.
sqrt
(
c1
*
c1
+
c2
*
c2
);
that
.
zoomed
=
true
;
scale
=
1
/
that
.
touchesDistStart
*
that
.
touchesDist
*
this
.
scale
;
if
(
scale
<
that
.
options
.
zoomMin
)
scale
=
0.5
*
that
.
options
.
zoomMin
*
Math
.
pow
(
2.0
,
scale
/
that
.
options
.
zoomMin
);
else
if
(
scale
>
that
.
options
.
zoomMax
)
scale
=
2.0
*
that
.
options
.
zoomMax
*
Math
.
pow
(
0.5
,
that
.
options
.
zoomMax
/
scale
);
that
.
lastScale
=
scale
/
this
.
scale
;
newX
=
this
.
originX
-
this
.
originX
*
that
.
lastScale
+
this
.
x
;
newY
=
this
.
originY
-
this
.
originY
*
that
.
lastScale
+
this
.
y
;
this
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
newX
+
'
px,
'
+
newY
+
'
px) scale(
'
+
scale
+
'
)
'
+
translateZ
;
if
(
that
.
options
.
onZoom
)
that
.
options
.
onZoom
.
call
(
that
,
e
);
return
;
}
that
.
pointX
=
point
.
pageX
;
that
.
pointY
=
point
.
pageY
;
// Slow down if outside of the boundaries
if
(
newX
>
0
||
newX
<
that
.
maxScrollX
)
{
newX
=
that
.
options
.
bounce
?
that
.
x
+
(
deltaX
/
2
)
:
newX
>=
0
||
that
.
maxScrollX
>=
0
?
0
:
that
.
maxScrollX
;
}
if
(
newY
>
that
.
minScrollY
||
newY
<
that
.
maxScrollY
)
{
newY
=
that
.
options
.
bounce
?
that
.
y
+
(
deltaY
/
2
)
:
newY
>=
that
.
minScrollY
||
that
.
maxScrollY
>=
0
?
that
.
minScrollY
:
that
.
maxScrollY
;
}
that
.
distX
+=
deltaX
;
that
.
distY
+=
deltaY
;
that
.
absDistX
=
m
.
abs
(
that
.
distX
);
that
.
absDistY
=
m
.
abs
(
that
.
distY
);
if
(
that
.
absDistX
<
6
&&
that
.
absDistY
<
6
)
{
return
;
}
// Lock direction
if
(
that
.
options
.
lockDirection
)
{
if
(
that
.
absDistX
>
that
.
absDistY
+
5
)
{
newY
=
that
.
y
;
deltaY
=
0
;
}
else
if
(
that
.
absDistY
>
that
.
absDistX
+
5
)
{
newX
=
that
.
x
;
deltaX
=
0
;
}
}
that
.
moved
=
true
;
that
.
_pos
(
newX
,
newY
);
that
.
dirX
=
deltaX
>
0
?
-
1
:
deltaX
<
0
?
1
:
0
;
that
.
dirY
=
deltaY
>
0
?
-
1
:
deltaY
<
0
?
1
:
0
;
if
(
timestamp
-
that
.
startTime
>
300
)
{
that
.
startTime
=
timestamp
;
that
.
startX
=
that
.
x
;
that
.
startY
=
that
.
y
;
}
if
(
that
.
options
.
onScrollMove
)
that
.
options
.
onScrollMove
.
call
(
that
,
e
);
},
_end
:
function
(
e
)
{
if
(
hasTouch
&&
e
.
touches
.
length
!==
0
)
return
;
var
that
=
this
,
point
=
hasTouch
?
e
.
changedTouches
[
0
]
:
e
,
target
,
ev
,
momentumX
=
{
dist
:
0
,
time
:
0
},
momentumY
=
{
dist
:
0
,
time
:
0
},
duration
=
(
e
.
timeStamp
||
Date
.
now
())
-
that
.
startTime
,
newPosX
=
that
.
x
,
newPosY
=
that
.
y
,
distX
,
distY
,
newDuration
,
snap
,
scale
;
if
(
that
.
options
.
onBeforeScrollEnd
)
that
.
options
.
onBeforeScrollEnd
.
call
(
that
,
e
);
if
(
that
.
zoomed
)
{
scale
=
that
.
scale
*
that
.
lastScale
;
scale
=
Math
.
max
(
that
.
options
.
zoomMin
,
scale
);
scale
=
Math
.
min
(
that
.
options
.
zoomMax
,
scale
);
that
.
lastScale
=
scale
/
that
.
scale
;
that
.
scale
=
scale
;
that
.
x
=
that
.
originX
-
that
.
originX
*
that
.
lastScale
+
that
.
x
;
that
.
y
=
that
.
originY
-
that
.
originY
*
that
.
lastScale
+
that
.
y
;
that
.
scroller
.
style
[
transitionDuration
]
=
'
200ms
'
;
that
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
that
.
x
+
'
px,
'
+
that
.
y
+
'
px) scale(
'
+
that
.
scale
+
'
)
'
+
translateZ
;
that
.
zoomed
=
false
;
that
.
refresh
();
if
(
that
.
options
.
onZoomEnd
)
that
.
options
.
onZoomEnd
.
call
(
that
,
e
);
return
;
}
if
(
!
that
.
moved
)
{
if
(
hasTouch
)
{
if
(
that
.
doubleTapTimer
&&
that
.
options
.
zoom
)
{
// Double tapped
clearTimeout
(
that
.
doubleTapTimer
);
that
.
doubleTapTimer
=
null
;
if
(
that
.
options
.
onZoomStart
)
that
.
options
.
onZoomStart
.
call
(
that
,
e
);
that
.
zoom
(
that
.
pointX
,
that
.
pointY
,
that
.
scale
==
1
?
that
.
options
.
doubleTapZoom
:
1
);
if
(
that
.
options
.
onZoomEnd
)
{
setTimeout
(
function
()
{
that
.
options
.
onZoomEnd
.
call
(
that
,
e
);
},
200
);
// 200 is default zoom duration
}
}
else
if
(
this
.
options
.
handleClick
)
{
that
.
doubleTapTimer
=
setTimeout
(
function
()
{
that
.
doubleTapTimer
=
null
;
// Find the last touched element
target
=
point
.
target
;
while
(
target
.
nodeType
!=
1
)
target
=
target
.
parentNode
;
if
(
target
.
tagName
!=
'
SELECT
'
&&
target
.
tagName
!=
'
INPUT
'
&&
target
.
tagName
!=
'
TEXTAREA
'
)
{
ev
=
doc
.
createEvent
(
'
MouseEvents
'
);
ev
.
initMouseEvent
(
'
click
'
,
true
,
true
,
e
.
view
,
1
,
point
.
screenX
,
point
.
screenY
,
point
.
clientX
,
point
.
clientY
,
e
.
ctrlKey
,
e
.
altKey
,
e
.
shiftKey
,
e
.
metaKey
,
0
,
null
);
ev
.
_fake
=
true
;
target
.
dispatchEvent
(
ev
);
}
},
that
.
options
.
zoom
?
250
:
0
);
}
}
that
.
_resetPos
(
400
);
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
return
;
}
if
(
duration
<
300
&&
that
.
options
.
momentum
)
{
momentumX
=
newPosX
?
that
.
_momentum
(
newPosX
-
that
.
startX
,
duration
,
-
that
.
x
,
that
.
scrollerW
-
that
.
wrapperW
+
that
.
x
,
that
.
options
.
bounce
?
that
.
wrapperW
:
0
)
:
momentumX
;
momentumY
=
newPosY
?
that
.
_momentum
(
newPosY
-
that
.
startY
,
duration
,
-
that
.
y
,
(
that
.
maxScrollY
<
0
?
that
.
scrollerH
-
that
.
wrapperH
+
that
.
y
-
that
.
minScrollY
:
0
),
that
.
options
.
bounce
?
that
.
wrapperH
:
0
)
:
momentumY
;
newPosX
=
that
.
x
+
momentumX
.
dist
;
newPosY
=
that
.
y
+
momentumY
.
dist
;
if
(
(
that
.
x
>
0
&&
newPosX
>
0
)
||
(
that
.
x
<
that
.
maxScrollX
&&
newPosX
<
that
.
maxScrollX
)
)
momentumX
=
{
dist
:
0
,
time
:
0
};
if
(
(
that
.
y
>
that
.
minScrollY
&&
newPosY
>
that
.
minScrollY
)
||
(
that
.
y
<
that
.
maxScrollY
&&
newPosY
<
that
.
maxScrollY
)
)
momentumY
=
{
dist
:
0
,
time
:
0
};
}
if
(
momentumX
.
dist
||
momentumY
.
dist
)
{
newDuration
=
m
.
max
(
m
.
max
(
momentumX
.
time
,
momentumY
.
time
),
10
);
// Do we need to snap?
if
(
that
.
options
.
snap
)
{
distX
=
newPosX
-
that
.
absStartX
;
distY
=
newPosY
-
that
.
absStartY
;
if
(
m
.
abs
(
distX
)
<
that
.
options
.
snapThreshold
&&
m
.
abs
(
distY
)
<
that
.
options
.
snapThreshold
)
{
that
.
scrollTo
(
that
.
absStartX
,
that
.
absStartY
,
200
);
}
else
{
snap
=
that
.
_snap
(
newPosX
,
newPosY
);
newPosX
=
snap
.
x
;
newPosY
=
snap
.
y
;
newDuration
=
m
.
max
(
snap
.
time
,
newDuration
);
}
}
that
.
scrollTo
(
m
.
round
(
newPosX
),
m
.
round
(
newPosY
),
newDuration
);
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
return
;
}
// Do we need to snap?
if
(
that
.
options
.
snap
)
{
distX
=
newPosX
-
that
.
absStartX
;
distY
=
newPosY
-
that
.
absStartY
;
if
(
m
.
abs
(
distX
)
<
that
.
options
.
snapThreshold
&&
m
.
abs
(
distY
)
<
that
.
options
.
snapThreshold
)
that
.
scrollTo
(
that
.
absStartX
,
that
.
absStartY
,
200
);
else
{
snap
=
that
.
_snap
(
that
.
x
,
that
.
y
);
if
(
snap
.
x
!=
that
.
x
||
snap
.
y
!=
that
.
y
)
that
.
scrollTo
(
snap
.
x
,
snap
.
y
,
snap
.
time
);
}
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
return
;
}
that
.
_resetPos
(
200
);
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
},
_resetPos
:
function
(
time
)
{
var
that
=
this
,
resetX
=
that
.
x
>=
0
?
0
:
that
.
x
<
that
.
maxScrollX
?
that
.
maxScrollX
:
that
.
x
,
resetY
=
that
.
y
>=
that
.
minScrollY
||
that
.
maxScrollY
>
0
?
that
.
minScrollY
:
that
.
y
<
that
.
maxScrollY
?
that
.
maxScrollY
:
that
.
y
;
if
(
resetX
==
that
.
x
&&
resetY
==
that
.
y
)
{
if
(
that
.
moved
)
{
that
.
moved
=
false
;
if
(
that
.
options
.
onScrollEnd
)
that
.
options
.
onScrollEnd
.
call
(
that
);
// Execute custom code on scroll end
}
if
(
that
.
hScrollbar
&&
that
.
options
.
hideScrollbar
)
{
if
(
vendor
==
'
webkit
'
)
that
.
hScrollbarWrapper
.
style
[
transitionDelay
]
=
'
300ms
'
;
that
.
hScrollbarWrapper
.
style
.
opacity
=
'
0
'
;
}
if
(
that
.
vScrollbar
&&
that
.
options
.
hideScrollbar
)
{
if
(
vendor
==
'
webkit
'
)
that
.
vScrollbarWrapper
.
style
[
transitionDelay
]
=
'
300ms
'
;
that
.
vScrollbarWrapper
.
style
.
opacity
=
'
0
'
;
}
return
;
}
that
.
scrollTo
(
resetX
,
resetY
,
time
||
0
);
},
_wheel
:
function
(
e
)
{
var
that
=
this
,
wheelDeltaX
,
wheelDeltaY
,
deltaX
,
deltaY
,
deltaScale
;
if
(
'
wheelDeltaX
'
in
e
)
{
wheelDeltaX
=
e
[
'
wheelDeltaX
'
]
/
12
;
wheelDeltaY
=
e
[
'
wheelDeltaY
'
]
/
12
;
}
else
if
(
'
wheelDelta
'
in
e
)
{
wheelDeltaX
=
wheelDeltaY
=
e
[
'
wheelDelta
'
]
/
12
;
}
else
if
(
'
detail
'
in
e
)
{
wheelDeltaX
=
wheelDeltaY
=
-
e
[
'
detail
'
]
*
3
;
}
else
{
return
;
}
if
(
that
.
options
.
wheelAction
==
'
zoom
'
)
{
deltaScale
=
that
.
scale
*
Math
.
pow
(
2
,
1
/
3
*
(
wheelDeltaY
?
wheelDeltaY
/
Math
.
abs
(
wheelDeltaY
)
:
0
)
);
if
(
deltaScale
<
that
.
options
.
zoomMin
)
deltaScale
=
that
.
options
.
zoomMin
;
if
(
deltaScale
>
that
.
options
.
zoomMax
)
deltaScale
=
that
.
options
.
zoomMax
;
if
(
deltaScale
!=
that
.
scale
)
{
if
(
!
that
.
wheelZoomCount
&&
that
.
options
.
onZoomStart
)
that
.
options
.
onZoomStart
.
call
(
that
,
e
);
that
.
wheelZoomCount
++
;
that
.
zoom
(
e
.
pageX
,
e
.
pageY
,
deltaScale
,
400
);
setTimeout
(
function
()
{
that
.
wheelZoomCount
--
;
if
(
!
that
.
wheelZoomCount
&&
that
.
options
.
onZoomEnd
)
that
.
options
.
onZoomEnd
.
call
(
that
,
e
);
},
400
);
}
return
;
}
deltaX
=
that
.
x
+
wheelDeltaX
;
deltaY
=
that
.
y
+
wheelDeltaY
;
if
(
deltaX
>
0
)
deltaX
=
0
;
else
if
(
deltaX
<
that
.
maxScrollX
)
deltaX
=
that
.
maxScrollX
;
if
(
deltaY
>
that
.
minScrollY
)
deltaY
=
that
.
minScrollY
;
else
if
(
deltaY
<
that
.
maxScrollY
)
deltaY
=
that
.
maxScrollY
;
if
(
that
.
maxScrollY
<
0
)
{
that
.
scrollTo
(
deltaX
,
deltaY
,
0
);
}
},
_transitionEnd
:
function
(
e
)
{
var
that
=
this
;
if
(
e
.
target
!=
that
.
scroller
)
return
;
that
.
_unbind
(
TRNEND_EV
);
that
.
_startAni
();
},
/**
*
* Utilities
*
*/
_startAni
:
function
()
{
var
that
=
this
,
startX
=
that
.
x
,
startY
=
that
.
y
,
startTime
=
Date
.
now
(),
step
,
easeOut
,
animate
;
if
(
that
.
animating
)
return
;
if
(
!
that
.
steps
.
length
)
{
that
.
_resetPos
(
400
);
return
;
}
step
=
that
.
steps
.
shift
();
if
(
step
.
x
==
startX
&&
step
.
y
==
startY
)
step
.
time
=
0
;
that
.
animating
=
true
;
that
.
moved
=
true
;
if
(
that
.
options
.
useTransition
)
{
that
.
_transitionTime
(
step
.
time
);
that
.
_pos
(
step
.
x
,
step
.
y
);
that
.
animating
=
false
;
if
(
step
.
time
)
that
.
_bind
(
TRNEND_EV
);
else
that
.
_resetPos
(
0
);
return
;
}
animate
=
function
()
{
var
now
=
Date
.
now
(),
newX
,
newY
;
if
(
now
>=
startTime
+
step
.
time
)
{
that
.
_pos
(
step
.
x
,
step
.
y
);
that
.
animating
=
false
;
if
(
that
.
options
.
onAnimationEnd
)
that
.
options
.
onAnimationEnd
(
that
);
// Execute custom code on animation end
that
.
_startAni
();
return
;
}
now
=
(
now
-
startTime
)
/
step
.
time
-
1
;
easeOut
=
m
.
sqrt
(
1
-
now
*
now
);
newX
=
(
step
.
x
-
startX
)
*
easeOut
+
startX
;
newY
=
(
step
.
y
-
startY
)
*
easeOut
+
startY
;
that
.
_pos
(
newX
,
newY
,
true
);
if
(
that
.
animating
)
that
.
aniTime
=
nextFrame
(
animate
);
};
animate
();
},
_transitionTime
:
function
(
time
)
{
time
+=
'
ms
'
;
this
.
scroller
.
style
[
transitionDuration
]
=
time
;
if
(
this
.
hScrollbar
)
this
.
hScrollbarIndicator
.
style
[
transitionDuration
]
=
time
;
if
(
this
.
vScrollbar
)
this
.
vScrollbarIndicator
.
style
[
transitionDuration
]
=
time
;
},
_momentum
:
function
(
dist
,
time
,
maxDistUpper
,
maxDistLower
,
size
)
{
var
deceleration
=
0.0006
,
speed
=
m
.
abs
(
dist
)
/
time
,
newDist
=
(
speed
*
speed
)
/
(
2
*
deceleration
),
newTime
=
0
,
outsideDist
=
0
;
// Proportinally reduce speed if we are outside of the boundaries
if
(
dist
>
0
&&
newDist
>
maxDistUpper
)
{
outsideDist
=
size
/
(
6
/
(
newDist
/
speed
*
deceleration
));
maxDistUpper
=
maxDistUpper
+
outsideDist
;
speed
=
speed
*
maxDistUpper
/
newDist
;
newDist
=
maxDistUpper
;
}
else
if
(
dist
<
0
&&
newDist
>
maxDistLower
)
{
outsideDist
=
size
/
(
6
/
(
newDist
/
speed
*
deceleration
));
maxDistLower
=
maxDistLower
+
outsideDist
;
speed
=
speed
*
maxDistLower
/
newDist
;
newDist
=
maxDistLower
;
}
newDist
=
newDist
*
(
dist
<
0
?
-
1
:
1
);
newTime
=
speed
/
deceleration
;
return
{
dist
:
newDist
,
time
:
m
.
round
(
newTime
)
};
},
_offset
:
function
(
el
)
{
var
left
=
-
el
.
offsetLeft
,
top
=
-
el
.
offsetTop
;
while
(
el
=
el
.
offsetParent
)
{
left
-=
el
.
offsetLeft
;
top
-=
el
.
offsetTop
;
}
if
(
el
!=
this
.
wrapper
)
{
left
*=
this
.
scale
;
top
*=
this
.
scale
;
}
return
{
left
:
left
,
top
:
top
};
},
_snap
:
function
(
x
,
y
)
{
var
that
=
this
,
i
,
l
,
page
,
time
,
sizeX
,
sizeY
;
// Check page X
page
=
that
.
pagesX
.
length
-
1
;
for
(
i
=
0
,
l
=
that
.
pagesX
.
length
;
i
<
l
;
i
++
)
{
if
(
x
>=
that
.
pagesX
[
i
]
)
{
page
=
i
;
break
;
}
}
if
(
page
==
that
.
currPageX
&&
page
>
0
&&
that
.
dirX
<
0
)
page
--
;
x
=
that
.
pagesX
[
page
];
sizeX
=
m
.
abs
(
x
-
that
.
pagesX
[
that
.
currPageX
]
);
sizeX
=
sizeX
?
m
.
abs
(
that
.
x
-
x
)
/
sizeX
*
500
:
0
;
that
.
currPageX
=
page
;
// Check page Y
page
=
that
.
pagesY
.
length
-
1
;
for
(
i
=
0
;
i
<
page
;
i
++
)
{
if
(
y
>=
that
.
pagesY
[
i
]
)
{
page
=
i
;
break
;
}
}
if
(
page
==
that
.
currPageY
&&
page
>
0
&&
that
.
dirY
<
0
)
page
--
;
y
=
that
.
pagesY
[
page
];
sizeY
=
m
.
abs
(
y
-
that
.
pagesY
[
that
.
currPageY
]
);
sizeY
=
sizeY
?
m
.
abs
(
that
.
y
-
y
)
/
sizeY
*
500
:
0
;
that
.
currPageY
=
page
;
// Snap with constant speed (proportional duration)
time
=
m
.
round
(
m
.
max
(
sizeX
,
sizeY
)
)
||
200
;
return
{
x
:
x
,
y
:
y
,
time
:
time
};
},
_bind
:
function
(
type
,
el
,
bubble
)
{
(
el
||
this
.
scroller
).
addEventListener
(
type
,
this
,
!!
bubble
);
},
_unbind
:
function
(
type
,
el
,
bubble
)
{
(
el
||
this
.
scroller
).
removeEventListener
(
type
,
this
,
!!
bubble
);
},
/**
*
* Public methods
*
*/
destroy
:
function
()
{
var
that
=
this
;
that
.
scroller
.
style
[
transform
]
=
''
;
// Remove the scrollbars
that
.
hScrollbar
=
false
;
that
.
vScrollbar
=
false
;
that
.
_scrollbar
(
'
h
'
);
that
.
_scrollbar
(
'
v
'
);
// Remove the event listeners
if
(
that
.
options
.
useTransition
)
that
.
_unbind
(
TRNEND_EV
);
if
(
that
.
options
.
onDestroy
)
that
.
options
.
onDestroy
.
call
(
that
);
},
_changeMaxes
:
function
()
{
var
that
=
this
;
var
_elem
=
that
.
api
.
ReaderModeDiv
;
that
.
scrollerW
=
m
.
round
(
_elem
.
offsetWidth
);
that
.
scrollerH
=
m
.
round
(
_elem
.
offsetHeight
+
that
.
minScrollY
);
that
.
maxScrollX
=
that
.
wrapperW
-
that
.
scrollerW
;
that
.
maxScrollY
=
that
.
wrapperH
-
that
.
scrollerH
+
that
.
minScrollY
;
that
.
_scrollbar
(
'
h
'
);
that
.
_scrollbar
(
'
v
'
);
},
refresh
:
function
(
bIsNoReaderAttack
)
{
var
that
=
this
,
offset
,
i
,
l
,
els
,
pos
=
0
,
page
=
0
;
if
(
that
.
scale
<
that
.
options
.
zoomMin
)
that
.
scale
=
that
.
options
.
zoomMin
;
that
.
wrapperW
=
((
that
.
wrapper
.
width
)
||
1
)
>>
0
;
that
.
wrapperH
=
((
that
.
wrapper
.
height
)
||
1
)
>>
0
;
that
.
minScrollY
=
0
;
that
.
scrollerW
=
that
.
api
.
m_dScrollX_max
;
that
.
scrollerH
=
that
.
api
.
m_dScrollY_max
;
var
_oldMaxX
=
that
.
maxScrollX
;
var
_oldMaxY
=
that
.
maxScrollY
;
var
_oldX
=
that
.
x
;
var
_oldY
=
that
.
y
;
that
.
maxScrollX
=
-
that
.
api
.
m_dScrollX_max
;
that
.
maxScrollY
=
-
that
.
api
.
m_dScrollY_max
;
that
.
x
=
-
that
.
api
.
m_dScrollX
;
that
.
y
=
-
that
.
api
.
m_dScrollY
;
if
(
that
.
api
.
ReaderModeDiv
!=
null
&&
undefined
===
bIsNoReaderAttack
)
{
var
_elem
=
that
.
api
.
ReaderModeDiv
;
that
.
scrollerW
=
m
.
round
(
_elem
.
offsetWidth
);
that
.
scrollerH
=
m
.
round
(
_elem
.
offsetHeight
+
that
.
minScrollY
);
that
.
maxScrollX
=
that
.
wrapperW
-
that
.
scrollerW
;
that
.
maxScrollY
=
that
.
wrapperH
-
that
.
scrollerH
+
that
.
minScrollY
;
// теперь посмотрим
/*
that.y = 0;
if (0 < that.api.m_dScrollY_max)
{
that.y = (that.api.m_dScrollY * that.maxScrollY / that.api.m_dScrollY_max) >> 0;
}
*/
that
.
x
=
0
;
that
.
y
=
0
;
if
(
_oldMaxX
<
0
)
{
that
.
x
=
(
_oldX
*
that
.
maxScrollX
/
_oldMaxX
)
>>
0
;
if
(
that
.
x
>
0
)
that
.
x
=
0
;
if
(
that
.
x
<
that
.
maxScrollX
)
that
.
x
=
that
.
maxScrollX
;
}
if
(
_oldMaxY
<
0
)
{
that
.
y
=
(
_oldY
*
that
.
maxScrollY
/
_oldMaxY
)
>>
0
;
if
(
that
.
y
>
0
)
that
.
y
=
0
;
if
(
that
.
y
<
that
.
maxScrollY
)
that
.
y
=
that
.
maxScrollY
;
}
}
that
.
dirX
=
0
;
that
.
dirY
=
0
;
if
(
that
.
options
.
onRefresh
)
that
.
options
.
onRefresh
.
call
(
that
);
that
.
hScroll
=
that
.
options
.
hScroll
&&
that
.
maxScrollX
<
0
;
that
.
vScroll
=
that
.
options
.
vScroll
&&
(
!
that
.
options
.
bounceLock
&&
!
that
.
hScroll
||
that
.
scrollerH
>=
that
.
wrapperH
);
that
.
hScrollbar
=
that
.
hScroll
&&
that
.
options
.
hScrollbar
;
that
.
vScrollbar
=
that
.
vScroll
&&
that
.
options
.
vScrollbar
&&
that
.
scrollerH
>=
that
.
wrapperH
;
offset
=
that
.
_offset
(
that
.
wrapper
);
that
.
wrapperOffsetLeft
=
-
offset
.
left
;
that
.
wrapperOffsetTop
=
-
offset
.
top
;
// Prepare snap
if
(
typeof
that
.
options
.
snap
==
'
string
'
)
{
that
.
pagesX
=
[];
that
.
pagesY
=
[];
els
=
that
.
scroller
.
querySelectorAll
(
that
.
options
.
snap
);
for
(
i
=
0
,
l
=
els
.
length
;
i
<
l
;
i
++
)
{
pos
=
that
.
_offset
(
els
[
i
]
);
pos
.
left
+=
that
.
wrapperOffsetLeft
;
pos
.
top
+=
that
.
wrapperOffsetTop
;
that
.
pagesX
[
i
]
=
pos
.
left
<
that
.
maxScrollX
?
that
.
maxScrollX
:
pos
.
left
*
that
.
scale
;
that
.
pagesY
[
i
]
=
pos
.
top
<
that
.
maxScrollY
?
that
.
maxScrollY
:
pos
.
top
*
that
.
scale
;
}
}
else
if
(
that
.
options
.
snap
)
{
that
.
pagesX
=
[];
while
(
pos
>=
that
.
maxScrollX
)
{
that
.
pagesX
[
page
]
=
pos
;
pos
=
pos
-
that
.
wrapperW
;
page
++
;
}
if
(
that
.
maxScrollX
%
that
.
wrapperW
)
that
.
pagesX
[
that
.
pagesX
.
length
]
=
that
.
maxScrollX
-
that
.
pagesX
[
that
.
pagesX
.
length
-
1
]
+
that
.
pagesX
[
that
.
pagesX
.
length
-
1
];
pos
=
0
;
page
=
0
;
that
.
pagesY
=
[];
while
(
pos
>=
that
.
maxScrollY
)
{
that
.
pagesY
[
page
]
=
pos
;
pos
=
pos
-
that
.
wrapperH
;
page
++
;
}
if
(
that
.
maxScrollY
%
that
.
wrapperH
)
that
.
pagesY
[
that
.
pagesY
.
length
]
=
that
.
maxScrollY
-
that
.
pagesY
[
that
.
pagesY
.
length
-
1
]
+
that
.
pagesY
[
that
.
pagesY
.
length
-
1
];
}
// Prepare the scrollbars
that
.
_scrollbar
(
'
h
'
);
that
.
_scrollbar
(
'
v
'
);
if
(
!
that
.
zoomed
&&
that
.
scroller
)
{
that
.
scroller
.
style
[
transitionDuration
]
=
'
0
'
;
that
.
_resetPos
(
400
);
}
},
scrollTo
:
function
(
x
,
y
,
time
,
relative
)
{
var
that
=
this
,
step
=
x
,
i
,
l
;
that
.
stop
();
if
(
!
step
.
length
)
step
=
[
{
x
:
x
,
y
:
y
,
time
:
time
,
relative
:
relative
}
];
for
(
i
=
0
,
l
=
step
.
length
;
i
<
l
;
i
++
)
{
if
(
step
[
i
].
relative
)
{
step
[
i
].
x
=
that
.
x
-
step
[
i
].
x
;
step
[
i
].
y
=
that
.
y
-
step
[
i
].
y
;
}
that
.
steps
.
push
(
{
x
:
step
[
i
].
x
,
y
:
step
[
i
].
y
,
time
:
step
[
i
].
time
||
0
}
);
}
that
.
_startAni
();
},
scrollToElement
:
function
(
el
,
time
)
{
var
that
=
this
,
pos
;
el
=
el
.
nodeType
?
el
:
that
.
scroller
.
querySelector
(
el
);
if
(
!
el
)
return
;
pos
=
that
.
_offset
(
el
);
pos
.
left
+=
that
.
wrapperOffsetLeft
;
pos
.
top
+=
that
.
wrapperOffsetTop
;
pos
.
left
=
pos
.
left
>
0
?
0
:
pos
.
left
<
that
.
maxScrollX
?
that
.
maxScrollX
:
pos
.
left
;
pos
.
top
=
pos
.
top
>
that
.
minScrollY
?
that
.
minScrollY
:
pos
.
top
<
that
.
maxScrollY
?
that
.
maxScrollY
:
pos
.
top
;
time
=
time
===
undefined
?
m
.
max
(
m
.
abs
(
pos
.
left
)
*
2
,
m
.
abs
(
pos
.
top
)
*
2
)
:
time
;
that
.
scrollTo
(
pos
.
left
,
pos
.
top
,
time
);
},
scrollToPage
:
function
(
pageX
,
pageY
,
time
)
{
var
that
=
this
,
x
,
y
;
time
=
time
===
undefined
?
400
:
time
;
if
(
that
.
options
.
onScrollStart
)
that
.
options
.
onScrollStart
.
call
(
that
);
if
(
that
.
options
.
snap
)
{
pageX
=
pageX
==
'
next
'
?
that
.
currPageX
+
1
:
pageX
==
'
prev
'
?
that
.
currPageX
-
1
:
pageX
;
pageY
=
pageY
==
'
next
'
?
that
.
currPageY
+
1
:
pageY
==
'
prev
'
?
that
.
currPageY
-
1
:
pageY
;
pageX
=
pageX
<
0
?
0
:
pageX
>
that
.
pagesX
.
length
-
1
?
that
.
pagesX
.
length
-
1
:
pageX
;
pageY
=
pageY
<
0
?
0
:
pageY
>
that
.
pagesY
.
length
-
1
?
that
.
pagesY
.
length
-
1
:
pageY
;
that
.
currPageX
=
pageX
;
that
.
currPageY
=
pageY
;
x
=
that
.
pagesX
[
pageX
];
y
=
that
.
pagesY
[
pageY
];
}
else
{
x
=
-
that
.
wrapperW
*
pageX
;
y
=
-
that
.
wrapperH
*
pageY
;
if
(
x
<
that
.
maxScrollX
)
x
=
that
.
maxScrollX
;
if
(
y
<
that
.
maxScrollY
)
y
=
that
.
maxScrollY
;
}
that
.
scrollTo
(
x
,
y
,
time
);
},
disable
:
function
()
{
this
.
stop
();
this
.
_resetPos
(
0
);
this
.
enabled
=
false
;
// If disabled after touchstart we make sure that there are no left over events
this
.
_unbind
(
CANCEL_EV
,
window
);
},
enable
:
function
()
{
this
.
enabled
=
true
;
},
stop
:
function
()
{
if
(
this
.
options
.
useTransition
)
this
.
_unbind
(
TRNEND_EV
);
else
cancelFrame
(
this
.
aniTime
);
this
.
steps
=
[];
this
.
moved
=
false
;
this
.
animating
=
false
;
},
zoom
:
function
(
x
,
y
,
scale
,
time
)
{
var
that
=
this
,
relScale
=
scale
/
that
.
scale
;
if
(
!
that
.
options
.
useTransform
)
return
;
that
.
zoomed
=
true
;
time
=
time
===
undefined
?
200
:
time
;
x
=
x
-
that
.
wrapperOffsetLeft
-
that
.
x
;
y
=
y
-
that
.
wrapperOffsetTop
-
that
.
y
;
that
.
x
=
x
-
x
*
relScale
+
that
.
x
;
that
.
y
=
y
-
y
*
relScale
+
that
.
y
;
that
.
scale
=
scale
;
that
.
refresh
();
that
.
x
=
that
.
x
>
0
?
0
:
that
.
x
<
that
.
maxScrollX
?
that
.
maxScrollX
:
that
.
x
;
that
.
y
=
that
.
y
>
that
.
minScrollY
?
that
.
minScrollY
:
that
.
y
<
that
.
maxScrollY
?
that
.
maxScrollY
:
that
.
y
;
if
(
that
.
scroller
){
that
.
scroller
.
style
[
transitionDuration
]
=
time
+
'
ms
'
;
that
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
that
.
x
+
'
px,
'
+
that
.
y
+
'
px) scale(
'
+
scale
+
'
)
'
+
translateZ
;
}
that
.
zoomed
=
false
;
},
isReady
:
function
()
{
return
!
this
.
moved
&&
!
this
.
zoomed
&&
!
this
.
animating
;
}
};
function
prefixStyle
(
style
)
{
if
(
vendor
===
''
)
return
style
;
style
=
style
.
charAt
(
0
).
toUpperCase
()
+
style
.
substr
(
1
);
return
vendor
+
style
;
}
dummyStyle
=
null
;
// for the sake of it
//---------------------------------------------------------export---------------------------------------------------
window
[
'
AscCommonExcel
'
]
=
window
[
'
AscCommonExcel
'
]
||
{};
window
[
"
AscCommonExcel
"
].
CTouchScroll
=
CTouchScroll
;
})(
window
,
document
);
cell/view/mobileTouch.js
View file @
ae3cf693
...
@@ -31,2085 +31,256 @@
...
@@ -31,2085 +31,256 @@
*/
*/
"
use strict
"
;
"
use strict
"
;
(
(
/**
/**
* @param {Window} window
* @param {Window} window
* @param {undefined} undefined
* @param {undefined} undefined
*/
*/
function
(
window
,
undefined
)
{
function
(
window
,
undefined
)
// Import
var
MATRIX_ORDER_PREPEND
=
AscCommon
.
MATRIX_ORDER_PREPEND
;
var
global_mouseEvent
=
AscCommon
.
global_mouseEvent
;
var
MobileTouchMode
=
{
None
:
0
,
Scroll
:
1
,
Zoom
:
2
,
Select
:
3
,
InlineObj
:
4
,
FlowObj
:
5
,
Cursor
:
6
,
TableMove
:
7
,
TableRuler
:
8
};
function
CMobileTouchManager
()
{
{
this
.
AnimateScroll
=
false
;
// Import
this
.
AnimateZoom
=
false
;
var
MATRIX_ORDER_PREPEND
=
AscCommon
.
MATRIX_ORDER_PREPEND
;
var
global_mouseEvent
=
AscCommon
.
global_mouseEvent
;
this
.
bIsTextSelected
=
false
;
this
.
bIsTextSelecting
=
false
;
var
MobileTouchMode
=
{
this
.
LogicDocument
=
null
;
None
:
0
,
this
.
DrawingDocument
=
null
;
Scroll
:
1
,
this
.
HtmlPage
=
null
;
Zoom
:
2
,
Select
:
3
,
this
.
Mode
=
0
;
InlineObj
:
4
,
FlowObj
:
5
,
this
.
ReadingGlassTime
=
750
;
Cursor
:
6
,
this
.
TimeDown
=
0
;
TableMove
:
7
,
this
.
DownPoint
=
null
;
TableRuler
:
8
this
.
DownPointOriginal
=
{
X
:
0
,
Y
:
0
};
};
this
.
MoveAfterDown
=
false
;
this
.
MoveMinDist
=
10
;
function
CMobileTouchManager
()
{
this
.
RectSelect1
=
null
;
this
.
AnimateScroll
=
false
;
this
.
RectSelect2
=
null
;
this
.
AnimateZoom
=
false
;
this
.
PageSelect1
=
0
;
this
.
bIsTextSelected
=
false
;
this
.
PageSelect2
=
0
;
this
.
bIsTextSelecting
=
false
;
this
.
CheckFirstRect
=
true
;
this
.
LogicDocument
=
null
;
this
.
TrackTargetEps
=
20
;
this
.
DrawingDocument
=
null
;
this
.
HtmlPage
=
null
;
this
.
ScrollH
=
0
;
this
.
ScrollV
=
0
;
this
.
Mode
=
0
;
this
.
ZoomDistance
=
0
;
this
.
ReadingGlassTime
=
750
;
this
.
ZoomValue
=
100
;
this
.
TimeDown
=
0
;
this
.
ZoomValueMin
=
50
;
this
.
DownPoint
=
null
;
this
.
ZoomValueMax
=
300
;
this
.
DownPointOriginal
=
{
X
:
0
,
Y
:
0
};
this
.
MoveAfterDown
=
false
;
this
.
iScroll
=
null
;
this
.
MoveMinDist
=
10
;
this
.
ctrl
=
null
;
this
.
RectSelect1
=
null
;
this
.
TableMovePoint
=
null
;
this
.
RectSelect2
=
null
;
this
.
TableHorRulerPoints
=
null
;
this
.
TableVerRulerPoints
=
null
;
this
.
PageSelect1
=
0
;
this
.
TableStartTrack_Check
=
false
;
this
.
PageSelect2
=
0
;
this
.
TableRulersRectOffset
=
5
;
this
.
CheckFirstRect
=
true
;
this
.
TableRulersRectSize
=
20
;
this
.
TrackTargetEps
=
20
;
this
.
TableCurrentMoveDir
=
-
1
;
this
.
ScrollH
=
0
;
this
.
TableCurrentMovePos
=
-
1
;
this
.
ScrollV
=
0
;
this
.
TableCurrentMoveValue
=
0
;
this
.
TableCurrentMoveValueOld
=
0
;
this
.
ZoomDistance
=
0
;
this
.
ZoomValue
=
100
;
this
.
TableCurrentMoveValueMin
=
null
;
this
.
ZoomValueMin
=
50
;
this
.
TableCurrentMoveValueMax
=
null
;
this
.
ZoomValueMax
=
300
;
this
.
ShowMenuTimerId
=
-
1
;
this
.
iScroll
=
null
;
this
.
ctrl
=
null
;
this
.
longTapFlag
=
false
;
this
.
longTapTimer
=
-
1
;
this
.
TableMovePoint
=
null
;
this
.
mylatesttap
=
null
;
this
.
TableHorRulerPoints
=
null
;
this
.
zoomFactor
=
1
;
this
.
TableVerRulerPoints
=
null
;
this
.
wasZoom
=
false
;
this
.
TableStartTrack_Check
=
false
;
this
.
canZoom
=
true
;
this
.
wasMove
=
false
;
this
.
TableRulersRectOffset
=
5
;
}
this
.
TableRulersRectSize
=
20
;
CMobileTouchManager
.
prototype
.
Init
=
function
(
ctrl
)
{
this
.
TableCurrentMoveDir
=
-
1
;
this
.
ctrl
=
ctrl
;
this
.
TableCurrentMovePos
=
-
1
;
this
.
iScroll
=
new
AscCommonExcel
.
CTouchScroll
(
ctrl
,{
hScrollbar
:
true
,
vScrollbar
:
true
,
momentum
:
false
}
/*, { onAnimationEnd : function(param) {
this
.
TableCurrentMoveValue
=
0
;
param.api.MobileTouchManager.OnScrollAnimationEnd();
this
.
TableCurrentMoveValueOld
=
0
;
} }*/
);
};
this
.
TableCurrentMoveValueMin
=
null
;
this
.
TableCurrentMoveValueMax
=
null
;
CMobileTouchManager
.
prototype
.
MoveCursorToPoint
=
function
(
e
)
{
this
.
ShowMenuTimerId
=
-
1
;
AscCommon
.
check_MouseMoveEvent
(
e
);
var
pos
=
this
.
DrawingDocument
.
ConvertCoordsFromCursor2
(
global_mouseEvent
.
X
,
global_mouseEvent
.
Y
);
this
.
longTapFlag
=
false
;
this
.
longTapTimer
=
-
1
;
var
old_click_count
=
global_mouseEvent
.
ClickCount
;
this
.
mylatesttap
=
null
;
global_mouseEvent
.
ClickCount
=
1
;
this
.
zoomFactor
=
1
;
this
.
wasZoom
=
false
;
var
nearPos
=
this
.
LogicDocument
.
Get_NearestPos
(
pos
.
Page
,
pos
.
X
,
pos
.
Y
);
this
.
canZoom
=
true
;
this
.
wasMove
=
false
;
this
.
DrawingDocument
.
NeedScrollToTargetFlag
=
true
;
}
this
.
LogicDocument
.
OnMouseDown
(
global_mouseEvent
,
nearPos
.
X
,
nearPos
.
Y
,
pos
.
Page
);
this
.
LogicDocument
.
OnMouseUp
(
global_mouseEvent
,
nearPos
.
X
,
nearPos
.
Y
,
pos
.
Page
);
CMobileTouchManager
.
prototype
.
CreateScrollerDiv
=
function
(
_wrapper
,
_id
)
this
.
DrawingDocument
.
NeedScrollToTargetFlag
=
false
;
{
var
_scroller
=
document
.
createElement
(
'
div
'
);
global_mouseEvent
.
ClickCount
=
old_click_count
;
var
_style
=
"
position: absolute; z-index: 0; margin: 0; padding: 0; -webkit-tap-highlight-color: rgba(0,0,0,0); width: 100%; heigth: 100%; display: block;
"
;
};
_style
+=
"
-webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0);
"
;
_style
+=
"
-webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
"
;
CMobileTouchManager
.
prototype
.
onTouchStart
=
function
(
e
)
_style
+=
"
-webkit-text-size-adjust: none; -moz-text-size-adjust: none; -ms-text-size-adjust: none; -o-text-size-adjust: none; text-size-adjust: none;
"
;
{
_scroller
.
style
=
_style
;
this
.
longTapFlag
=
true
;
this
.
wasMove
=
false
;
_scroller
.
id
=
_id
;
var
thas
=
this
,
evt
=
e
,
_wrapper
.
appendChild
(
_scroller
);
point
=
arguments
[
0
].
touches
?
arguments
[
0
].
touches
[
0
]
:
arguments
[
0
];
};
function
longTapDetected
(){
CMobileTouchManager
.
prototype
.
Init
=
function
(
ctrl
)
if
(
thas
.
longTapFlag
)
{
alert
(
"
clientX
"
+
point
.
clientX
+
"
clientY
"
+
point
.
clientY
)
this
.
ctrl
=
ctrl
;
thas
.
longTapFlag
=
false
;
clearInterval
(
this
.
longTapTimer
);
this
.
CreateScrollerDiv
(
this
.
ctrl
.
element
,
"
mobile_scroller_id
"
);
}
this
.
iScroll
=
new
window
.
IScroll
(
this
.
ctrl
.
element
,
{
this
.
DownPointOriginal
.
X
=
point
.
clientX
;
scrollbars
:
true
,
this
.
DownPointOriginal
.
Y
=
point
.
clientY
;
mouseWheel
:
true
,
interactiveScrollbars
:
true
,
this
.
iScroll
.
_start
(
e
);
shrinkScrollbars
:
'
scale
'
,
e
.
preventDefault
();
fadeScrollbars
:
true
,
e
.
returnValue
=
false
;
scrollX
:
true
,
scroller_id
:
"
mobile_scroller_id
"
,
bounce
:
false
,
momentum
:
false
});
this
.
iScroll
.
manager
=
this
;
this
.
iScroll
.
on
(
'
scroll
'
,
function
()
{
var
_api
=
this
.
manager
.
ctrl
;
if
(
this
.
directionLocked
==
"
v
"
)
{
_api
.
_onScrollY
(
-
this
.
y
/
_api
.
controller
.
settings
.
hscrollStep
);
}
else
if
(
this
.
directionLocked
==
"
h
"
)
{
_api
.
_onScrollX
(
-
this
.
x
/
_api
.
controller
.
settings
.
vscrollStep
);
}
else
if
(
this
.
directionLocked
==
"
n
"
)
{
_api
.
_onScrollX
(
-
this
.
x
/
_api
.
controller
.
settings
.
vscrollStep
);
_api
.
_onScrollY
(
-
this
.
y
/
_api
.
controller
.
settings
.
hscrollStep
);
}
});
};
CMobileTouchManager
.
prototype
.
MoveCursorToPoint
=
function
(
e
)
{
AscCommon
.
check_MouseMoveEvent
(
e
);
var
pos
=
this
.
DrawingDocument
.
ConvertCoordsFromCursor2
(
global_mouseEvent
.
X
,
global_mouseEvent
.
Y
);
var
old_click_count
=
global_mouseEvent
.
ClickCount
;
global_mouseEvent
.
ClickCount
=
1
;
var
nearPos
=
this
.
LogicDocument
.
Get_NearestPos
(
pos
.
Page
,
pos
.
X
,
pos
.
Y
);
this
.
DrawingDocument
.
NeedScrollToTargetFlag
=
true
;
this
.
LogicDocument
.
OnMouseDown
(
global_mouseEvent
,
nearPos
.
X
,
nearPos
.
Y
,
pos
.
Page
);
this
.
LogicDocument
.
OnMouseUp
(
global_mouseEvent
,
nearPos
.
X
,
nearPos
.
Y
,
pos
.
Page
);
this
.
DrawingDocument
.
NeedScrollToTargetFlag
=
false
;
global_mouseEvent
.
ClickCount
=
old_click_count
;
};
CMobileTouchManager
.
prototype
.
onTouchStart
=
function
(
e
)
{
this
.
longTapFlag
=
true
;
this
.
wasMove
=
false
;
var
thas
=
this
,
evt
=
e
,
point
=
arguments
[
0
].
touches
?
arguments
[
0
].
touches
[
0
]
:
arguments
[
0
];
function
longTapDetected
()
{
if
(
thas
.
longTapFlag
)
alert
(
"
clientX
"
+
point
.
clientX
+
"
clientY
"
+
point
.
clientY
)
thas
.
longTapFlag
=
false
;
clearInterval
(
this
.
longTapTimer
);
}
this
.
DownPointOriginal
.
X
=
point
.
clientX
;
this
.
DownPointOriginal
.
Y
=
point
.
clientY
;
this
.
iScroll
.
_start
(
e
);
e
.
preventDefault
();
e
.
returnValue
=
false
;
// this.longTapTimer = setTimeout(longTapDetected,1000,e);
// this.longTapTimer = setTimeout(longTapDetected,1000,e);
return
false
;
return
false
;
// if (null != this.DrawingDocument.m_oDocumentRenderer)
};
// return this.onTouchStart_renderer(e);
CMobileTouchManager
.
prototype
.
onTouchMove
=
function
(
e
)
//
{
// check_MouseDownEvent(e.touches ? e.touches[0] : e, true);
this
.
longTapFlag
=
false
;
// global_mouseEvent.LockMouse();
this
.
wasMove
=
true
;
// this.HtmlPage.m_oApi.sendEvent("asc_onHidePopMenu");
/* this.ScrollH = this.HtmlPage.m_dScrollX;
this.ScrollV = this.HtmlPage.m_dScrollY;
this.TableCurrentMoveValueMin = null;
this.TableCurrentMoveValueMax = null;
this.MoveAfterDown = false;
this.TimeDown = new Date().getTime();
var bIsKoefPixToMM = false;
var _matrix = this.DrawingDocument.TextMatrix;
if (_matrix && global_MatrixTransformer.IsIdentity(_matrix))
_matrix = null;*/
// проверим на попадание в селект - это может произойти на любом mode
/* if (null != this.RectSelect1 && null != this.RectSelect2)
{
var pos1 = null;
var pos4 = null;
if (!_matrix)
{
pos1 = this.DrawingDocument.ConvertCoordsToCursor3(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1);
pos4 = this.DrawingDocument.ConvertCoordsToCursor3(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h, this.PageSelect2);
}
else
{
var _xx1 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y);
var _yy1 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y);
var _xx2 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
var _yy2 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
pos1 = this.DrawingDocument.ConvertCoordsToCursor3(_xx1, _yy1, this.PageSelect1);
pos4 = this.DrawingDocument.ConvertCoordsToCursor3(_xx2, _yy2, this.PageSelect2);
}
if (Math.abs(pos1.X - global_mouseEvent.X) < this.TrackTargetEps && Math.abs(pos1.Y - global_mouseEvent.Y) < this.TrackTargetEps)
{
this.Mode = MobileTouchMode.Select;
this.DragSelect = 1;
}
else if (Math.abs(pos4.X - global_mouseEvent.X) < this.TrackTargetEps && Math.abs(pos4.Y - global_mouseEvent.Y) < this.TrackTargetEps)
{
this.Mode = MobileTouchMode.Select;
this.DragSelect = 2;
}
}
else
{
var _xOffset = this.HtmlPage.X;
var _yOffset = this.HtmlPage.Y;
if (true === this.HtmlPage.m_bIsRuler)
{
_xOffset += (5 * g_dKoef_mm_to_pix);
_yOffset += (7 * g_dKoef_mm_to_pix);
}
var _eps = this.TrackTargetEps;
var bIsTable = false;
var _table_outline_dr = this.DrawingDocument.TableOutlineDr;
if (this.TableMovePoint != null && _table_outline_dr)
{
var _Transform = _table_outline_dr.TableMatrix;
var _PageNum = _table_outline_dr.CurrentPageIndex;
if (!_Transform || global_MatrixTransformer.IsIdentity(_Transform))
{
var _x = global_mouseEvent.X - _xOffset;
var _y = global_mouseEvent.Y - _yOffset;
var posLT = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableMovePoint.X, this.TableMovePoint.Y, _PageNum);
var _offset = this.TableRulersRectSize + this.TableRulersRectOffset;
if (_x > (posLT.X - _offset - _eps) && _x < (posLT.X - this.TableRulersRectOffset + _eps) &&
_y > (posLT.Y - _offset - _eps) && _y < (posLT.Y - this.TableRulersRectOffset + _eps))
{
this.Mode = MobileTouchMode.TableMove;
bIsTable = true;
}
if (!bIsTable)
{
if (_y > (posLT.Y - _offset - _eps) && _y < (posLT.Y - this.TableRulersRectOffset + _eps))
{
var _len = this.TableHorRulerPoints.length;
var _indexF = -1;
var _minF = 1000000;
for (var i = 0; i < _len; i++)
{
var posM1 = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableHorRulerPoints[i].C, this.TableMovePoint.Y, _PageNum);
var _dist = Math.abs(_x - posM1.X);
if (_minF > _dist)
{
_indexF = i;
_minF = _dist;
}
}
if (_minF < _eps)
{
var _p = this.TableHorRulerPoints[_indexF];
this.TableCurrentMoveDir = 0;
this.TableCurrentMovePos = _indexF;
this.TableCurrentMoveValue = _p.X;
this.TableCurrentMoveValueOld = this.TableCurrentMoveValue;
this.Mode = MobileTouchMode.TableRuler;
if (_indexF == 0)
{
this.TableCurrentMoveValueMin = this.TableMovePoint.X;
}
else
{
this.TableCurrentMoveValueMin = this.TableHorRulerPoints[_indexF - 1].X + this.TableHorRulerPoints[_indexF - 1].W;
}
if (_indexF < (_len - 1))
{
this.TableCurrentMoveValueMax = this.TableHorRulerPoints[_indexF + 1].X;
}
else
{
this.TableCurrentMoveValueMax = null;
}
bIsTable = true;
}
}
if (!bIsTable && _x >= (posLT.X - _offset - _eps) && _x <= (posLT.X - this.TableRulersRectOffset + _eps))
{
var _len = this.TableVerRulerPoints.length;
var _indexF = -1;
var _minF = 1000000;
for (var i = 0; i < _len; i++)
{
var posM1 = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableMovePoint.X, this.TableVerRulerPoints[i].Y, _PageNum);
var posM2 = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableMovePoint.X, this.TableVerRulerPoints[i].Y + this.TableVerRulerPoints[i].H, _PageNum);
if (_y >= (posM1.Y - _eps) && _y <= (posM2.Y + _eps))
{
var _dist = Math.abs(_y - ((posM1.Y + posM2.Y) / 2));
if (_minF > _dist)
{
_indexF = i;
_minF = _dist;
}
}
}
if (_indexF != -1)
{
var _p = this.TableVerRulerPoints[_indexF];
this.TableCurrentMoveDir = 1;
this.TableCurrentMovePos = _indexF;
this.TableCurrentMoveValue = _p.Y;
this.TableCurrentMoveValueOld = this.TableCurrentMoveValue;
this.Mode = MobileTouchMode.TableRuler;
if (_indexF == 0)
{
this.TableCurrentMoveValueMin = this.TableMovePoint.Y;
}
else
{
this.TableCurrentMoveValueMin = this.TableVerRulerPoints[_indexF - 1].Y + this.TableVerRulerPoints[_indexF - 1].H;
}
if (_indexF < (_len - 1))
{
this.TableCurrentMoveValueMax = this.TableVerRulerPoints[_indexF + 1].Y;
}
else
{
this.TableCurrentMoveValueMax = null;
}
bIsTable = true;
}
}
}
}
else
{
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
if (pos.Page == _PageNum)
{
var _invert = global_MatrixTransformer.Invert(_Transform);
var _posx = _invert.TransformPointX(pos.X, pos.Y);
var _posy = _invert.TransformPointY(pos.X, pos.Y);
var _koef = g_dKoef_pix_to_mm * 100 / this.HtmlPage.m_nZoomValue;
var _eps1 = this.TrackTargetEps * _koef;
var _offset1 = this.TableRulersRectOffset * _koef;
var _offset2 = _offset1 + this.TableRulersRectSize * _koef;
if ((_posx >= (this.TableMovePoint.X - _offset2 - _eps1)) && (_posx <= (this.TableMovePoint.X - _offset1 + _eps1)) &&
(_posy >= (this.TableMovePoint.Y - _offset2 - _eps1)) && (_posy <= (this.TableMovePoint.Y - _offset1 + _eps1)))
{
this.Mode = MobileTouchMode.TableMove;
bIsTable = true;
}
if (!bIsTable)
{
if (_posy > (this.TableMovePoint.Y - _offset2 - _eps1) && _posy < (this.TableMovePoint.Y - _offset1 + _eps1))
{
var _len = this.TableHorRulerPoints.length;
for (var i = 0; i < _len; i++)
{
var _p = this.TableHorRulerPoints[i];
if (_posx > (_p.X - _eps1) && _posx < (_p.X + _p.W + _eps1))
{
this.TableCurrentMoveDir = 0;
this.TableCurrentMovePos = i;
this.TableCurrentMoveValue = this.TableHorRulerPoints[i].X;
this.TableCurrentMoveValueOld = this.TableCurrentMoveValue;
this.Mode = MobileTouchMode.TableRuler;
if (i == 0)
{
this.TableCurrentMoveValueMin = this.TableMovePoint.X;
}
else
{
this.TableCurrentMoveValueMin = this.TableHorRulerPoints[i - 1].X + this.TableHorRulerPoints[i - 1].W;
}
if (i < (_len - 1))
{
this.TableCurrentMoveValueMax = this.TableHorRulerPoints[i + 1].X;
}
else
{
this.TableCurrentMoveValueMax = null;
}
bIsTable = true;
break;
}
}
}
if (!bIsTable && _posx >= (this.TableMovePoint.X - _offset2 - _eps1) && _posx <= (this.TableMovePoint.X - _offset1 + _eps1))
{
var _len = this.TableVerRulerPoints.length;
for (var i = 0; i < _len; i++)
{
var _p = this.TableVerRulerPoints[i];
if (_posy >= (_p.Y - _eps1) && _posy <= (_p.Y + _p.H + _eps1))
{
this.TableCurrentMoveDir = 1;
this.TableCurrentMovePos = i;
this.TableCurrentMoveValue = this.TableVerRulerPoints[i].Y;
this.TableCurrentMoveValueOld = this.TableCurrentMoveValue;
this.Mode = MobileTouchMode.TableRuler;
if (i == 0)
{
this.TableCurrentMoveValueMin = this.TableMovePoint.Y;
}
else
{
this.TableCurrentMoveValueMin = this.TableVerRulerPoints[i - 1].Y + this.TableVerRulerPoints[i - 1].H;
}
if (i < (_len - 1))
{
this.TableCurrentMoveValueMax = this.TableVerRulerPoints[i + 1].Y;
}
else
{
this.TableCurrentMoveValueMax = null;
}
bIsTable = true;
break;
}
}
}
}
}
}
}
if (!bIsTable)
{
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
var dKoef = (100 * g_dKoef_pix_to_mm / this.HtmlPage.m_nZoomValue);
global_mouseEvent.KoefPixToMM = 5;
if (this.LogicDocument.DrawingObjects.isPointInDrawingObjects2(pos.X, pos.Y, pos.Page))
{
bIsKoefPixToMM = true;
this.Mode = MobileTouchMode.FlowObj;
}
else
{
this.Mode = MobileTouchMode.None;
}
global_mouseEvent.KoefPixToMM = 1;
}
}
if (e.touches && 2 == e.touches.length)
{
this.Mode = MobileTouchMode.Zoom;
}
switch (this.Mode)
{
case MobileTouchMode.None:
{
this.Mode = MobileTouchMode.Scroll;
this.DownPoint = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
this.DownPointOriginal.X = global_mouseEvent.X;
this.DownPointOriginal.Y = global_mouseEvent.Y;
this.iScroll._start(e);
break;
}
case MobileTouchMode.Scroll:
{
// ничего не меняем, просто перемещаем точку
this.DownPoint = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
this.DownPointOriginal.X = global_mouseEvent.X;
this.DownPointOriginal.Y = global_mouseEvent.Y;
this.iScroll._start(e);
break;
}
case MobileTouchMode.Select:
{
if (1 == this.DragSelect)
{
global_mouseEvent.Button = 0;
if (!_matrix)
{
this.LogicDocument.OnMouseDown(global_mouseEvent, this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h / 2, this.PageSelect2);
}
else
{
var __X = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h / 2);
var __Y = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h / 2);
this.LogicDocument.OnMouseDown(global_mouseEvent, __X, __Y, this.PageSelect2);
}
var pos1 = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
this.LogicDocument.OnMouseMove(global_mouseEvent, pos1.X, pos1.Y, pos1.Page);
}
else if (2 == this.DragSelect)
{
global_mouseEvent.Button = 0;
if (!_matrix)
{
this.LogicDocument.OnMouseDown(global_mouseEvent, this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h / 2, this.PageSelect1);
}
else
{
var __X = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h / 2);
var __Y = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h / 2);
this.LogicDocument.OnMouseDown(global_mouseEvent, __X, __Y, this.PageSelect1);
}
var pos4 = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
this.LogicDocument.OnMouseMove(global_mouseEvent, pos4.X, pos4.Y, pos4.Page);
}
break;
}
case MobileTouchMode.InlineObj:
{
break;
}
case MobileTouchMode.FlowObj:
{
// так как был уже check, нужно уменьшить количество кликов
if (global_mouseEvent.ClickCount > 0)
global_mouseEvent.ClickCount--;
if (bIsKoefPixToMM)
{
global_mouseEvent.KoefPixToMM = 5;
}
this.HtmlPage.onMouseDown(e.touches ? e.touches[0] : e);
global_mouseEvent.KoefPixToMM = 1;
break;
}
case MobileTouchMode.Zoom:
{
this.HtmlPage.NoneRepaintPages = true;
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX;
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
this.ZoomDistance = Math.sqrt((_x1 - _x2)*(_x1 - _x2) + (_y1 - _y2)*(_y1 - _y2));
this.ZoomValue = this.HtmlPage.m_nZoomValue;
break;
}
case MobileTouchMode.Cursor:
{
this.Mode = MobileTouchMode.Scroll;
this.DownPoint = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
break;
}
case MobileTouchMode.TableMove:
{
// так как был уже check, нужно уменьшить количество кликов
if (global_mouseEvent.ClickCount > 0)
global_mouseEvent.ClickCount--;
this.HtmlPage.onMouseDown(e.touches ? e.touches[0] : e);
break;
}
case MobileTouchMode.TableRuler:
{
this.HtmlPage.OnUpdateOverlay();
break;
}
}
if (this.HtmlPage.m_oApi.isViewMode)
{
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
return false;
}*/
};
CMobileTouchManager
.
prototype
.
onTouchMove
=
function
(
e
)
{
this
.
longTapFlag
=
false
;
this
.
wasMove
=
true
;
// clearInterval(this.longTapTimer);
// clearInterval(this.longTapTimer);
this
.
iScroll
.
_move
(
e
);
this
.
iScroll
.
_move
(
e
);
e
.
preventDefault
();
e
.
preventDefault
();
e
.
returnValue
=
false
;
e
.
returnValue
=
false
;
// this.canZoom = false;
// this.canZoom = false;
return
false
;
return
false
;
/* if (null != this.DrawingDocument.m_oDocumentRenderer)
};
return this.onTouchMove_renderer(e);
CMobileTouchManager
.
prototype
.
onTouchEnd
=
function
(
e
)
{
if (this.Mode != MobileTouchMode.FlowObj && this.Mode != MobileTouchMode.TableMove)
this
.
longTapFlag
=
false
;
check_MouseMoveEvent(e.touches ? e.touches[0] : e);
if (!this.MoveAfterDown)
{
if (Math.abs(this.DownPointOriginal.X - global_mouseEvent.X) > this.MoveMinDist ||
Math.abs(this.DownPointOriginal.Y - global_mouseEvent.Y) > this.MoveMinDist)
{
this.MoveAfterDown = true;
}
}
switch (this.Mode)
{
case MobileTouchMode.Cursor:
{
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
var old_click_count = global_mouseEvent.ClickCount;
global_mouseEvent.ClickCount = 1;
var nearPos = this.LogicDocument.Get_NearestPos(pos.Page, pos.X, pos.Y);
this.DrawingDocument.NeedScrollToTargetFlag = true;
global_mouseEvent.Type = g_mouse_event_type_down;
this.LogicDocument.OnMouseDown(global_mouseEvent, nearPos.X, nearPos.Y + nearPos.Height / 2, pos.Page);
global_mouseEvent.Type = g_mouse_event_type_up;
this.LogicDocument.OnMouseUp(global_mouseEvent, nearPos.X, nearPos.Y + nearPos.Height / 2, pos.Page);
this.DrawingDocument.NeedScrollToTargetFlag = false;
global_mouseEvent.ClickCount = old_click_count;
break;
}
case MobileTouchMode.Scroll:
{
var _newTime = new Date().getTime();
if ((_newTime - this.TimeDown) > this.ReadingGlassTime && !this.MoveAfterDown)
{
this.Mode = MobileTouchMode.Cursor;
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
var old_click_count = global_mouseEvent.ClickCount;
global_mouseEvent.ClickCount = 1;
var nearPos = this.LogicDocument.Get_NearestPos(pos.Page, pos.X, pos.Y);
this.DrawingDocument.NeedScrollToTargetFlag = true;
global_mouseEvent.Type = g_mouse_event_type_down;
this.LogicDocument.OnMouseDown(global_mouseEvent, nearPos.X, nearPos.Y, pos.Page);
global_mouseEvent.Type = g_mouse_event_type_up;
this.LogicDocument.OnMouseUp(global_mouseEvent, nearPos.X, nearPos.Y, pos.Page);
this.DrawingDocument.NeedScrollToTargetFlag = false;
global_mouseEvent.ClickCount = old_click_count;
}
else
{
var _offsetX = global_mouseEvent.X - this.DownPointOriginal.X;
var _offsetY = global_mouseEvent.Y - this.DownPointOriginal.Y;
this.iScroll._move(e);
// if (_offsetX != 0 && this.HtmlPage.m_dScrollX_max > 0)
// {
// this.HtmlPage.m_oScrollHorApi.scrollToX(this.ScrollH - _offsetX);
// }
// if (_offsetY != 0 && this.HtmlPage.m_dScrollY_max > 0)
// {
// this.HtmlPage.m_oScrollVerApi.scrollToY(this.ScrollV - _offsetY);
// }
e.preventDefault();
e.returnValue = false;
}
break;
}
case MobileTouchMode.Zoom:
{
if (2 != e.touches.length)
{
this.Mode = MobileTouchMode.None;
return;
}
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX;
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
var zoomCurrentDist = Math.sqrt((_x1 - _x2)*(_x1 - _x2) + (_y1 - _y2)*(_y1 - _y2));
if (zoomCurrentDist == 0)
zoomCurrentDist = 1;
var _zoomFix = this.ZoomValue / 100;
var _zoomCur = _zoomFix * (zoomCurrentDist / this.ZoomDistance);
_zoomCur = (_zoomCur * 100) >> 0;
if (_zoomCur < this.ZoomValueMin)
_zoomCur = this.ZoomValueMin;
else if (_zoomCur > this.ZoomValueMax)
_zoomCur = this.ZoomValueMax;
this.HtmlPage.m_oApi.zoom(_zoomCur);
break;
}
case MobileTouchMode.InlineObj:
{
break;
}
case MobileTouchMode.FlowObj:
{
this.HtmlPage.onMouseMove(e.touches ? e.touches[0] : e);
break;
}
case MobileTouchMode.Select:
{
// во время движения может смениться порядок ректов
global_mouseEvent.ClickCount = 1;
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
this.LogicDocument.OnMouseMove(global_mouseEvent, pos.X, pos.Y, pos.Page);
break;
}
case MobileTouchMode.TableMove:
{
this.HtmlPage.onMouseMove(e.touches ? e.touches[0] : e);
break;
}
case MobileTouchMode.TableRuler:
{
var pos = this.DrawingDocument.ConvertCoordsFromCursorPage(global_mouseEvent.X, global_mouseEvent.Y, this.DrawingDocument.TableOutlineDr.CurrentPageIndex);
var _Transform = null;
if (this.DrawingDocument.TableOutlineDr)
_Transform = this.DrawingDocument.TableOutlineDr.TableMatrix;
if (_Transform && !global_MatrixTransformer.IsIdentity(_Transform))
{
var _invert = _Transform.CreateDublicate();
_invert.Invert();
var __x = _invert.TransformPointX(pos.X, pos.Y);
var __y = _invert.TransformPointY(pos.X, pos.Y);
pos.X = __x;
pos.Y = __y;
}
if (this.TableCurrentMoveDir == 0)
{
this.TableCurrentMoveValue = pos.X;
if (null != this.TableCurrentMoveValueMin)
{
if (this.TableCurrentMoveValueMin > this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMin;
}
if (null != this.TableCurrentMoveValueMax)
{
if (this.TableCurrentMoveValueMax < this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMax;
}
}
else
{
this.TableCurrentMoveValue = pos.Y;
if (null != this.TableCurrentMoveValueMin)
{
if (this.TableCurrentMoveValueMin > this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMin;
}
if (null != this.TableCurrentMoveValueMax)
{
if (this.TableCurrentMoveValueMax < this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMax;
}
}
this.HtmlPage.OnUpdateOverlay();
break;
}
default:
break;
}*/
};
CMobileTouchManager
.
prototype
.
onTouchEnd
=
function
(
e
)
{
this
.
longTapFlag
=
false
;
// clearInterval(this.longTapTimer);
// clearInterval(this.longTapTimer);
this
.
iScroll
.
_end
(
e
);
this
.
iScroll
.
_end
(
e
);
var
now
=
new
Date
().
getTime
(),
point
=
e
.
changedTouches
?
e
.
changedTouches
[
0
]
:
e
;
var
now
=
new
Date
().
getTime
(),
point
=
e
.
changedTouches
?
e
.
changedTouches
[
0
]
:
e
;
/* this.mylatesttap = this.mylatesttap||now+1
/* this.mylatesttap = this.mylatesttap||now+1
var timesince = now - this.mylatesttap;
var timesince = now - this.mylatesttap;
if((timesince < 300) && (timesince > 0)){
if((timesince < 300) && (timesince > 0)){
// this.ctrl.handlers.trigger("asc_onDoubleTapEvent",e);
// this.ctrl.handlers.trigger("asc_onDoubleTapEvent",e);
this.mylatesttap = null;
this.mylatesttap = null;
if ( this.wasZoom ) {
if ( this.wasZoom ) {
this.zoomFactor = 1;
this.zoomFactor = 1;
this.wasZoom = false;
this.wasZoom = false;
}
}
else {
else {
this.zoomFactor = 2;
this.zoomFactor = 2;
this.wasZoom = true;
this.wasZoom = true;
}
}
this.ctrl._onScrollY(0);
this.ctrl._onScrollY(0);
this.ctrl._onScrollX(0);
this.ctrl._onScrollX(0);
this.ctrl.changeZoom( this.zoomFactor );
this.ctrl.changeZoom( this.zoomFactor );
this.iScroll.zoom( point.clientX, point.clientY, this.zoomFactor );
this.iScroll.zoom( point.clientX, point.clientY, this.zoomFactor );
}else{
}else{
// too much time to be a doubletap
// too much time to be a doubletap
this.mylatesttap = now+1;
this.mylatesttap = now+1;
}*/
}*/
if
(
Math
.
abs
(
this
.
DownPointOriginal
.
X
-
point
.
clientX
)
<
this
.
ctrl
.
controller
.
settings
.
hscrollStep
&&
Math
.
abs
(
this
.
DownPointOriginal
.
Y
-
point
.
clientY
)
<
this
.
ctrl
.
controller
.
settings
.
vscrollStep
)
if
(
Math
.
abs
(
this
.
DownPointOriginal
.
X
-
point
.
clientX
)
<
this
.
ctrl
.
controller
.
settings
.
hscrollStep
&&
Math
.
abs
(
this
.
DownPointOriginal
.
Y
-
point
.
clientY
)
<
this
.
ctrl
.
controller
.
settings
.
vscrollStep
)
this
.
ctrl
.
handlers
.
trigger
(
"
asc_onTapEvent
"
,
e
);
this
.
ctrl
.
handlers
.
trigger
(
"
asc_onTapEvent
"
,
e
);
e
.
preventDefault
();
e
.
preventDefault
();
e
.
returnValue
=
false
;
e
.
returnValue
=
false
;
this
.
wasMove
=
false
;
this
.
wasMove
=
false
;
return
;
return
;
/*
};
if (null != this.DrawingDocument.m_oDocumentRenderer)
return this.onTouchEnd_renderer(e);
CMobileTouchManager
.
prototype
.
Resize
=
function
()
{
if (this.Mode != MobileTouchMode.FlowObj && this.Mode != MobileTouchMode.TableMove)
if
(
this
.
iScroll
!=
null
)
check_MouseUpEvent(e.changedTouches ? e.changedTouches[0] : e);
{
var
_api
=
this
.
ctrl
;
this.ScrollH = this.HtmlPage.m_dScrollX;
var
_pixelW
=
_api
.
element
.
clientWidth
+
_api
.
m_dScrollX_max
;
this.ScrollV = this.HtmlPage.m_dScrollY;
var
_pixelH
=
_api
.
element
.
clientHeight
+
_api
.
m_dScrollY_max
;
switch (this.Mode)
this
.
iScroll
.
scroller
.
style
.
width
=
_pixelW
+
"
px
"
;
{
this
.
iScroll
.
scroller
.
style
.
height
=
_pixelH
+
"
px
"
;
case MobileTouchMode.Cursor:
{
this
.
iScroll
.
refresh
();
// ничего не делаем. курсор уже установлен
}
this.Mode = MobileTouchMode.None;
};
break;
}
//--------------------------------------------------------export----------------------------------------------------
case MobileTouchMode.Scroll:
window
[
'
AscCommonExcel
'
]
=
window
[
'
AscCommonExcel
'
]
||
{};
{
window
[
'
AscCommonExcel
'
].
CMobileTouchManager
=
CMobileTouchManager
;
if (!this.MoveAfterDown)
{
global_mouseEvent.Button = 0;
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
this.LogicDocument.OnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page);
global_mouseEvent.Type = g_mouse_event_type_up;
this.LogicDocument.OnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page);
this.LogicDocument.Document_UpdateInterfaceState();
var horRuler = this.HtmlPage.m_oHorRuler;
var _oldRulerType = horRuler.CurrentObjectType;
this.LogicDocument.Document_UpdateRulersState();
if (horRuler.CurrentObjectType != _oldRulerType)
this.HtmlPage.OnUpdateOverlay();
this.LogicDocument.Update_CursorType(pos.X, pos.Y, pos.Page, global_mouseEvent);
this.HtmlPage.m_oApi.sendEvent("asc_onTapEvent", e);
}
else
{
// нужно запускать анимацию скролла, если она есть
// TODO:
this.iScroll._end(e);
}
this.Mode = MobileTouchMode.None;
break;
}
case MobileTouchMode.Zoom:
{
// здесь нужно запускать отрисовку, если есть анимация зума
this.HtmlPage.NoneRepaintPages = false;
this.HtmlPage.m_bIsFullRepaint = true;
this.HtmlPage.OnScroll();
this.Mode = MobileTouchMode.None;
break;
}
case MobileTouchMode.InlineObj:
{
// TODO:
break;
}
case MobileTouchMode.FlowObj:
{
// TODO:
this.HtmlPage.onMouseUp(e.changedTouches ? e.changedTouches[0] : e);
this.Mode = MobileTouchMode.None;
break;
}
case MobileTouchMode.Select:
{
// ничего не нужно делать
this.DragSelect = 0;
this.Mode = MobileTouchMode.None;
break;
}
case MobileTouchMode.TableMove:
{
this.HtmlPage.onMouseUp(e.changedTouches ? e.changedTouches[0] : e);
this.Mode = MobileTouchMode.None;
break;
}
case MobileTouchMode.TableRuler:
{
this.HtmlPage.StartUpdateOverlay();
this.Mode = MobileTouchMode.None;
var _xOffset = this.HtmlPage.X;
var _yOffset = this.HtmlPage.Y;
if (true === this.HtmlPage.m_bIsRuler)
{
_xOffset += (5 * g_dKoef_mm_to_pix);
_yOffset += (7 * g_dKoef_mm_to_pix);
}
var pos = this.DrawingDocument.ConvertCoordsFromCursorPage(global_mouseEvent.X, global_mouseEvent.Y, this.DrawingDocument.TableOutlineDr.CurrentPageIndex);
var _Transform = null;
if (this.DrawingDocument.TableOutlineDr)
_Transform = this.DrawingDocument.TableOutlineDr.TableMatrix;
if (_Transform && !global_MatrixTransformer.IsIdentity(_Transform))
{
var _invert = _Transform.CreateDublicate();
_invert.Invert();
var __x = _invert.TransformPointX(pos.X, pos.Y);
var __y = _invert.TransformPointY(pos.X, pos.Y);
pos.X = __x;
pos.Y = __y;
}
if (this.TableCurrentMoveDir == 0)
{
this.TableCurrentMoveValue = pos.X;
if (null != this.TableCurrentMoveValueMin)
{
if (this.TableCurrentMoveValueMin > this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMin;
}
if (null != this.TableCurrentMoveValueMax)
{
if (this.TableCurrentMoveValueMax < this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMax;
}
var _markup = this.HtmlPage.m_oHorRuler.m_oTableMarkup;
_markup.Cols[this.TableCurrentMovePos] += (this.TableCurrentMoveValue - this.TableCurrentMoveValueOld);
_markup.Cols[this.TableCurrentMovePos] = Math.max(_markup.Cols[this.TableCurrentMovePos], 1);
_markup.Table.Update_TableMarkupFromRuler(_markup, true, this.TableCurrentMovePos + 1);
}
else
{
this.TableCurrentMoveValue = pos.Y;
if (null != this.TableCurrentMoveValueMin)
{
if (this.TableCurrentMoveValueMin > this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMin;
}
if (null != this.TableCurrentMoveValueMax)
{
if (this.TableCurrentMoveValueMax < this.TableCurrentMoveValue)
this.TableCurrentMoveValue = this.TableCurrentMoveValueMax;
}
var _markup = this.HtmlPage.m_oHorRuler.m_oTableMarkup;
_markup.Rows[this.TableCurrentMovePos].H += (this.TableCurrentMoveValue - this.TableCurrentMoveValueOld);
_markup.Table.Update_TableMarkupFromRuler(_markup, false, this.TableCurrentMovePos + 1);
}
this.HtmlPage.OnUpdateOverlay();
this.HtmlPage.EndUpdateOverlay();
break;
}
default:
break;
}
this.iScroll._scrollbar('h');
this.iScroll._scrollbar('v');
if (this.HtmlPage.m_oApi.isViewMode)
{
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
return false;
}
// если есть селект - то показать меню
this.CheckSelectEnd(true);*/
};
CMobileTouchManager
.
prototype
.
onTouchStart_renderer
=
function
(
e
)
{
AscCommon
.
check_MouseDownEvent
(
e
.
touches
?
e
.
touches
[
0
]
:
e
,
true
);
global_mouseEvent
.
LockMouse
();
this
.
ScrollH
=
this
.
HtmlPage
.
m_dScrollX
;
this
.
ScrollV
=
this
.
HtmlPage
.
m_dScrollY
;
this
.
MoveAfterDown
=
false
;
if
(
e
.
touches
&&
2
==
e
.
touches
.
length
)
{
this
.
Mode
=
MobileTouchMode
.
Zoom
;
}
switch
(
this
.
Mode
)
{
case
MobileTouchMode
.
None
:
{
this
.
Mode
=
MobileTouchMode
.
Scroll
;
this
.
DownPoint
=
this
.
DrawingDocument
.
ConvertCoordsFromCursor2
(
global_mouseEvent
.
X
,
global_mouseEvent
.
Y
);
this
.
DownPointOriginal
.
X
=
global_mouseEvent
.
X
;
this
.
DownPointOriginal
.
Y
=
global_mouseEvent
.
Y
;
this
.
iScroll
.
_start
(
e
);
break
;
}
case
MobileTouchMode
.
Scroll
:
{
// ничего не меняем, просто перемещаем точку
this
.
DownPoint
=
this
.
DrawingDocument
.
ConvertCoordsFromCursor2
(
global_mouseEvent
.
X
,
global_mouseEvent
.
Y
);
this
.
DownPointOriginal
.
X
=
global_mouseEvent
.
X
;
this
.
DownPointOriginal
.
Y
=
global_mouseEvent
.
Y
;
this
.
iScroll
.
_start
(
e
);
break
;
}
case
MobileTouchMode
.
Zoom
:
{
this
.
HtmlPage
.
NoneRepaintPages
=
true
;
var
_x1
=
(
e
.
touches
[
0
].
pageX
!==
undefined
)
?
e
.
touches
[
0
].
pageX
:
e
.
touches
[
0
].
clientX
;
var
_y1
=
(
e
.
touches
[
0
].
pageY
!==
undefined
)
?
e
.
touches
[
0
].
pageY
:
e
.
touches
[
0
].
clientY
;
var
_x2
=
(
e
.
touches
[
1
].
pageX
!==
undefined
)
?
e
.
touches
[
1
].
pageX
:
e
.
touches
[
1
].
clientX
;
var
_y2
=
(
e
.
touches
[
1
].
pageY
!==
undefined
)
?
e
.
touches
[
1
].
pageY
:
e
.
touches
[
1
].
clientY
;
this
.
ZoomDistance
=
Math
.
sqrt
((
_x1
-
_x2
)
*
(
_x1
-
_x2
)
+
(
_y1
-
_y2
)
*
(
_y1
-
_y2
));
this
.
ZoomValue
=
this
.
HtmlPage
.
m_nZoomValue
;
break
;
}
}
if
(
e
.
preventDefault
)
e
.
preventDefault
();
else
e
.
returnValue
=
false
;
};
CMobileTouchManager
.
prototype
.
onTouchMove_renderer
=
function
(
e
)
{
AscCommon
.
check_MouseMoveEvent
(
e
.
touches
?
e
.
touches
[
0
]
:
e
);
if
(
!
this
.
MoveAfterDown
)
{
if
(
Math
.
abs
(
this
.
DownPointOriginal
.
X
-
global_mouseEvent
.
X
)
>
this
.
MoveMinDist
||
Math
.
abs
(
this
.
DownPointOriginal
.
Y
-
global_mouseEvent
.
Y
)
>
this
.
MoveMinDist
)
{
this
.
MoveAfterDown
=
true
;
}
}
switch
(
this
.
Mode
)
{
case
MobileTouchMode
.
Scroll
:
{
var
_offsetX
=
global_mouseEvent
.
X
-
this
.
DownPointOriginal
.
X
;
var
_offsetY
=
global_mouseEvent
.
Y
-
this
.
DownPointOriginal
.
Y
;
this
.
iScroll
.
_move
(
e
);
break
;
}
case
MobileTouchMode
.
Zoom
:
{
if
(
2
!=
e
.
touches
.
length
)
{
this
.
Mode
=
MobileTouchMode
.
None
;
return
;
}
var
_x1
=
(
e
.
touches
[
0
].
pageX
!==
undefined
)
?
e
.
touches
[
0
].
pageX
:
e
.
touches
[
0
].
clientX
;
var
_y1
=
(
e
.
touches
[
0
].
pageY
!==
undefined
)
?
e
.
touches
[
0
].
pageY
:
e
.
touches
[
0
].
clientY
;
var
_x2
=
(
e
.
touches
[
1
].
pageX
!==
undefined
)
?
e
.
touches
[
1
].
pageX
:
e
.
touches
[
1
].
clientX
;
var
_y2
=
(
e
.
touches
[
1
].
pageY
!==
undefined
)
?
e
.
touches
[
1
].
pageY
:
e
.
touches
[
1
].
clientY
;
var
zoomCurrentDist
=
Math
.
sqrt
((
_x1
-
_x2
)
*
(
_x1
-
_x2
)
+
(
_y1
-
_y2
)
*
(
_y1
-
_y2
));
if
(
zoomCurrentDist
==
0
)
zoomCurrentDist
=
1
;
var
_zoomFix
=
this
.
ZoomValue
/
100
;
var
_zoomCur
=
_zoomFix
*
(
zoomCurrentDist
/
this
.
ZoomDistance
);
_zoomCur
=
(
_zoomCur
*
100
)
>>
0
;
if
(
_zoomCur
<
this
.
ZoomValueMin
)
_zoomCur
=
this
.
ZoomValueMin
;
else
if
(
_zoomCur
>
this
.
ZoomValueMax
)
_zoomCur
=
this
.
ZoomValueMax
;
this
.
HtmlPage
.
m_oApi
.
zoom
(
_zoomCur
);
break
;
}
default
:
break
;
}
if
(
e
.
preventDefault
)
e
.
preventDefault
();
else
e
.
returnValue
=
false
;
};
CMobileTouchManager
.
prototype
.
onTouchEnd_renderer
=
function
(
e
)
{
AscCommon
.
check_MouseUpEvent
(
e
.
changedTouches
?
e
.
changedTouches
[
0
]
:
e
);
this
.
ScrollH
=
this
.
HtmlPage
.
m_dScrollX
;
this
.
ScrollV
=
this
.
HtmlPage
.
m_dScrollY
;
switch
(
this
.
Mode
)
{
case
MobileTouchMode
.
Scroll
:
{
this
.
iScroll
.
_end
(
e
);
this
.
Mode
=
MobileTouchMode
.
None
;
if
(
!
this
.
MoveAfterDown
)
{
this
.
HtmlPage
.
m_oApi
.
sendEvent
(
"
asc_onTapEvent
"
,
e
);
}
break
;
}
case
MobileTouchMode
.
Zoom
:
{
// здесь нужно запускать отрисовку, если есть анимация зума
this
.
HtmlPage
.
NoneRepaintPages
=
false
;
this
.
HtmlPage
.
m_bIsFullRepaint
=
true
;
this
.
HtmlPage
.
OnScroll
();
this
.
Mode
=
MobileTouchMode
.
None
;
break
;
}
default
:
break
;
}
this
.
iScroll
.
_scrollbar
(
'
h
'
);
this
.
iScroll
.
_scrollbar
(
'
v
'
);
if
(
e
.
preventDefault
)
e
.
preventDefault
();
else
e
.
returnValue
=
false
;
};
CMobileTouchManager
.
prototype
.
CheckSelectEnd
=
function
(
bIsAttack
)
{
var
_bIsRet
=
false
;
if
(
!
bIsAttack
)
_bIsRet
=
this
.
IsTrackingCurrent
;
if
(
_bIsRet
)
return
;
if
(
null
!=
this
.
RectSelect1
&&
null
!=
this
.
RectSelect2
&&
!
this
.
HtmlPage
.
m_oApi
.
isViewMode
)
{
var
_matrix
=
this
.
DrawingDocument
.
TextMatrix
;
var
pos1
=
null
;
var
pos4
=
null
;
if
(
!
_matrix
||
AscCommon
.
global_MatrixTransformer
.
IsIdentity
(
_matrix
))
{
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
,
this
.
PageSelect1
);
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
,
this
.
PageSelect2
);
}
else
{
var
_x1
=
_matrix
.
TransformPointX
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_y1
=
_matrix
.
TransformPointY
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_x2
=
_matrix
.
TransformPointX
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
var
_y2
=
_matrix
.
TransformPointY
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_x1
,
_y1
,
this
.
PageSelect1
);
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_x2
,
_y2
,
this
.
PageSelect2
);
}
var
_x
=
(
pos1
.
X
+
pos4
.
X
)
>>
1
;
var
_y
=
pos1
.
Y
;
if
(
!
this
.
iScroll
.
animating
)
this
.
SendShowMenu
(
_x
,
_y
);
}
};
CMobileTouchManager
.
prototype
.
CheckZoomCriticalValues
=
function
(
zoomMin
)
{
if
(
zoomMin
!==
undefined
)
{
this
.
ZoomValueMin
=
zoomMin
;
return
;
}
var
w
=
this
.
HtmlPage
.
m_oEditor
.
AbsolutePosition
.
R
-
this
.
HtmlPage
.
m_oEditor
.
AbsolutePosition
.
L
;
var
Zoom
=
100
;
if
(
0
!=
this
.
HtmlPage
.
m_dDocumentPageWidth
)
{
Zoom
=
100
*
(
w
-
10
)
/
this
.
HtmlPage
.
m_dDocumentPageWidth
;
if
(
Zoom
<
5
)
Zoom
=
5
;
if
(
this
.
HtmlPage
.
m_oApi
.
isMobileVersion
)
{
var
_w
=
this
.
HtmlPage
.
m_oEditor
.
HtmlElement
.
width
;
if
(
this
.
bIsRetinaSupport
)
{
_w
>>=
1
;
}
Zoom
=
100
*
_w
*
AscCommon
.
g_dKoef_pix_to_mm
/
this
.
HtmlPage
.
m_dDocumentPageWidth
;
}
}
var
_new_value
=
(
Zoom
-
0.5
)
>>
0
;
this
.
ZoomValueMin
=
_new_value
;
if
(
this
.
ZoomValue
<
this
.
ZoomValueMin
)
{
this
.
ZoomValue
=
this
.
ZoomValueMin
;
this
.
HtmlPage
.
m_oApi
.
zoom
(
this
.
ZoomValue
);
}
};
CMobileTouchManager
.
prototype
.
Resize
=
function
()
{
if
(
this
.
iScroll
!=
null
)
this
.
iScroll
.
refresh
(
true
);
};
CMobileTouchManager
.
prototype
.
SendShowMenu
=
function
(
x
,
y
)
{
if
(
-
1
!=
this
.
ShowMenuTimerId
)
{
clearTimeout
(
this
.
ShowMenuTimerId
);
}
var
that
=
this
;
that
.
ShowMenuTimerId
=
setTimeout
(
function
(){
that
.
HtmlPage
.
m_oApi
.
sendEvent
(
"
asc_onShowPopMenu
"
,
x
,
y
);
},
500
);
};
CMobileTouchManager
.
prototype
.
OnScrollAnimationEnd
=
function
()
{
if
(
this
.
HtmlPage
.
m_oApi
.
isViewMode
)
return
;
if
(
null
!=
this
.
RectSelect1
&&
null
!=
this
.
RectSelect2
)
{
var
pos1
=
null
;
var
pos4
=
null
;
var
_matrix
=
this
.
DrawingDocument
.
TextMatrix
;
if
(
!
_matrix
||
AscCommon
.
global_MatrixTransformer
.
IsIdentity
(
_matrix
))
{
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
,
this
.
PageSelect1
);
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
,
this
.
PageSelect2
);
}
else
{
var
_x1
=
_matrix
.
TransformPointX
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_y1
=
_matrix
.
TransformPointY
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_x2
=
_matrix
.
TransformPointX
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
var
_y2
=
_matrix
.
TransformPointY
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_x1
,
_y1
,
this
.
PageSelect1
);
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_x2
,
_y2
,
this
.
PageSelect2
);
}
var
_x
=
(
pos1
.
X
+
pos4
.
X
)
>>
1
;
var
_y
=
pos1
.
Y
;
this
.
SendShowMenu
(
_x
,
_y
);
}
};
CMobileTouchManager
.
prototype
.
CheckSelect
=
function
(
overlay
)
{
if
(
null
==
this
.
RectSelect1
||
null
==
this
.
RectSelect2
)
return
;
var
_matrix
=
this
.
DrawingDocument
.
TextMatrix
;
if
(
!
_matrix
||
AscCommon
.
global_MatrixTransformer
.
IsIdentity
(
_matrix
))
{
var
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
,
this
.
PageSelect1
);
var
pos2
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
+
this
.
RectSelect1
.
h
,
this
.
PageSelect1
);
var
pos3
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
,
this
.
PageSelect2
);
var
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
,
this
.
PageSelect2
);
var
ctx
=
overlay
.
m_oContext
;
ctx
.
strokeStyle
=
"
#1B63BA
"
;
ctx
.
moveTo
(
pos1
.
X
>>
0
,
pos1
.
Y
>>
0
);
ctx
.
lineTo
(
pos2
.
X
>>
0
,
pos2
.
Y
>>
0
);
ctx
.
moveTo
(
pos3
.
X
>>
0
,
pos3
.
Y
>>
0
);
ctx
.
lineTo
(
pos4
.
X
>>
0
,
pos4
.
Y
>>
0
);
ctx
.
lineWidth
=
2
;
ctx
.
stroke
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
rgba(0, 0, 0, 0.5)
"
;
overlay
.
AddEllipse
(
pos1
.
X
,
pos1
.
Y
-
5
,
6.5
);
overlay
.
AddEllipse
(
pos4
.
X
,
pos4
.
Y
+
5
,
6.5
);
ctx
.
fill
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
#FFFFFF
"
;
overlay
.
AddEllipse
(
pos1
.
X
,
pos1
.
Y
-
5
,
6
);
overlay
.
AddEllipse
(
pos4
.
X
,
pos4
.
Y
+
5
,
6
);
ctx
.
fill
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
#1B63BA
"
;
overlay
.
AddEllipse
(
pos1
.
X
,
pos1
.
Y
-
5
,
5
);
overlay
.
AddEllipse
(
pos4
.
X
,
pos4
.
Y
+
5
,
5
);
ctx
.
fill
();
/*
ctx.beginPath();
ctx.fillStyle = "#FFFFFF";
overlay.AddEllipse(pos1.X, pos1.Y - 5, 2);
overlay.AddEllipse(pos4.X, pos4.Y + 5, 2);
ctx.fill();
*/
}
else
{
var
_xx11
=
_matrix
.
TransformPointX
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_yy11
=
_matrix
.
TransformPointY
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_xx12
=
_matrix
.
TransformPointX
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
+
this
.
RectSelect1
.
h
);
var
_yy12
=
_matrix
.
TransformPointY
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
+
this
.
RectSelect1
.
h
);
var
_xx21
=
_matrix
.
TransformPointX
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
);
var
_yy21
=
_matrix
.
TransformPointY
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
);
var
_xx22
=
_matrix
.
TransformPointX
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
var
_yy22
=
_matrix
.
TransformPointY
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
var
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx11
,
_yy11
,
this
.
PageSelect1
);
var
pos2
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx12
,
_yy12
,
this
.
PageSelect1
);
var
pos3
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx21
,
_yy21
,
this
.
PageSelect2
);
var
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx22
,
_yy22
,
this
.
PageSelect2
);
var
ctx
=
overlay
.
m_oContext
;
ctx
.
strokeStyle
=
"
#1B63BA
"
;
ctx
.
moveTo
(
pos1
.
X
,
pos1
.
Y
);
ctx
.
lineTo
(
pos2
.
X
,
pos2
.
Y
);
ctx
.
moveTo
(
pos3
.
X
,
pos3
.
Y
);
ctx
.
lineTo
(
pos4
.
X
,
pos4
.
Y
);
ctx
.
lineWidth
=
2
;
ctx
.
stroke
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
rgba(0, 0, 0, 0.5)
"
;
overlay
.
AddEllipse
(
pos1
.
X
,
pos1
.
Y
-
5
,
6.5
);
overlay
.
AddEllipse
(
pos4
.
X
,
pos4
.
Y
+
5
,
6.5
);
ctx
.
fill
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
#FFFFFF
"
;
overlay
.
AddEllipse
(
pos1
.
X
,
pos1
.
Y
-
5
,
6
);
overlay
.
AddEllipse
(
pos4
.
X
,
pos4
.
Y
+
5
,
6
);
ctx
.
fill
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
#1B63BA
"
;
overlay
.
AddEllipse
(
pos1
.
X
,
pos1
.
Y
-
5
,
5
);
overlay
.
AddEllipse
(
pos4
.
X
,
pos4
.
Y
+
5
,
5
);
ctx
.
fill
();
}
};
CMobileTouchManager
.
prototype
.
CheckSelect2
=
function
(
overlay
)
{
if
(
null
==
this
.
RectSelect1
||
null
==
this
.
RectSelect2
)
return
;
var
_matrix
=
this
.
DrawingDocument
.
TextMatrix
;
if
(
!
_matrix
||
AscCommon
.
global_MatrixTransformer
.
IsIdentity
(
_matrix
))
{
var
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
,
this
.
PageSelect1
);
var
pos2
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
+
this
.
RectSelect1
.
h
,
this
.
PageSelect1
);
var
pos3
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
,
this
.
PageSelect2
);
var
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
,
this
.
PageSelect2
);
var
ctx
=
overlay
.
m_oContext
;
ctx
.
strokeStyle
=
"
#1B63BA
"
;
ctx
.
moveTo
(
pos1
.
X
>>
0
,
pos1
.
Y
>>
0
);
ctx
.
lineTo
(
pos2
.
X
>>
0
,
pos2
.
Y
>>
0
);
ctx
.
moveTo
(
pos3
.
X
>>
0
,
pos3
.
Y
>>
0
);
ctx
.
lineTo
(
pos4
.
X
>>
0
,
pos4
.
Y
>>
0
);
ctx
.
lineWidth
=
2
;
ctx
.
stroke
();
ctx
.
beginPath
();
if
(
!
window
.
g_table_track_round
.
asc_complete
)
return
;
var
_w
=
window
.
g_table_track_round
.
width
;
var
_h
=
window
.
g_table_track_round
.
height
;
var
_x1
=
(
pos1
.
X
-
(
_w
/
2
))
>>
0
;
var
_y1
=
(
pos1
.
Y
-
5
-
(
_h
/
2
))
>>
0
;
var
_x2
=
(
pos4
.
X
-
(
_w
/
2
))
>>
0
;
var
_y2
=
(
pos4
.
Y
+
5
-
(
_h
/
2
))
>>
0
;
ctx
.
drawImage
(
window
.
g_table_track_round
,
_x1
,
_y1
);
ctx
.
drawImage
(
window
.
g_table_track_round
,
_x2
,
_y2
);
overlay
.
CheckRect
(
_x1
,
_y1
,
_w
,
_h
);
overlay
.
CheckRect
(
_x2
,
_y2
,
_w
,
_h
);
}
else
{
var
_xx11
=
_matrix
.
TransformPointX
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_yy11
=
_matrix
.
TransformPointY
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
);
var
_xx12
=
_matrix
.
TransformPointX
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
+
this
.
RectSelect1
.
h
);
var
_yy12
=
_matrix
.
TransformPointY
(
this
.
RectSelect1
.
x
,
this
.
RectSelect1
.
y
+
this
.
RectSelect1
.
h
);
var
_xx21
=
_matrix
.
TransformPointX
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
);
var
_yy21
=
_matrix
.
TransformPointY
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
);
var
_xx22
=
_matrix
.
TransformPointX
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
var
_yy22
=
_matrix
.
TransformPointY
(
this
.
RectSelect2
.
x
+
this
.
RectSelect2
.
w
,
this
.
RectSelect2
.
y
+
this
.
RectSelect2
.
h
);
var
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx11
,
_yy11
,
this
.
PageSelect1
);
var
pos2
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx12
,
_yy12
,
this
.
PageSelect1
);
var
pos3
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx21
,
_yy21
,
this
.
PageSelect2
);
var
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_xx22
,
_yy22
,
this
.
PageSelect2
);
var
ctx
=
overlay
.
m_oContext
;
ctx
.
strokeStyle
=
"
#1B63BA
"
;
ctx
.
moveTo
(
pos1
.
X
,
pos1
.
Y
);
ctx
.
lineTo
(
pos2
.
X
,
pos2
.
Y
);
ctx
.
moveTo
(
pos3
.
X
,
pos3
.
Y
);
ctx
.
lineTo
(
pos4
.
X
,
pos4
.
Y
);
ctx
.
lineWidth
=
2
;
ctx
.
stroke
();
ctx
.
beginPath
();
if
(
!
window
.
g_table_track_round
.
asc_complete
)
return
;
var
ex01
=
_matrix
.
TransformPointX
(
0
,
0
);
var
ey01
=
_matrix
.
TransformPointY
(
0
,
0
);
var
ex11
=
_matrix
.
TransformPointX
(
0
,
1
);
var
ey11
=
_matrix
.
TransformPointY
(
0
,
1
);
var
_len
=
Math
.
sqrt
((
ex11
-
ex01
)
*
(
ex11
-
ex01
)
+
(
ey11
-
ey01
)
*
(
ey11
-
ey01
));
if
(
_len
==
0
)
_len
=
0.01
;
var
ex
=
5
*
(
ex11
-
ex01
)
/
_len
;
var
ey
=
5
*
(
ey11
-
ey01
)
/
_len
;
var
_w
=
window
.
g_table_track_round
.
width
;
var
_h
=
window
.
g_table_track_round
.
height
;
var
_x1
=
(
pos1
.
X
-
ex
-
(
_w
/
2
))
>>
0
;
var
_y1
=
(
pos1
.
Y
-
ey
-
(
_h
/
2
))
>>
0
;
var
_x2
=
(
pos4
.
X
+
ex
-
(
_w
/
2
))
>>
0
;
var
_y2
=
(
pos4
.
Y
+
ey
-
(
_h
/
2
))
>>
0
;
ctx
.
drawImage
(
window
.
g_table_track_round
,
_x1
,
_y1
);
ctx
.
drawImage
(
window
.
g_table_track_round
,
_x2
,
_y2
);
overlay
.
CheckRect
(
_x1
,
_y1
,
_w
,
_h
);
overlay
.
CheckRect
(
_x2
,
_y2
,
_w
,
_h
);
}
};
CMobileTouchManager
.
prototype
.
CheckTableRules
=
function
(
overlay
)
{
if
(
this
.
HtmlPage
.
m_oApi
.
isViewMode
)
return
;
var
horRuler
=
this
.
HtmlPage
.
m_oHorRuler
;
var
verRuler
=
this
.
HtmlPage
.
m_oVerRuler
;
var
_table_outline_dr
=
this
.
DrawingDocument
.
TableOutlineDr
;
var
_tableOutline
=
_table_outline_dr
.
TableOutline
;
if
(
horRuler
.
CurrentObjectType
!=
RULER_OBJECT_TYPE_TABLE
||
verRuler
.
CurrentObjectType
!=
RULER_OBJECT_TYPE_TABLE
||
!
_tableOutline
)
{
this
.
TableMovePoint
=
null
;
this
.
TableHorRulerPoints
=
null
;
this
.
TableVerRulerPoints
=
null
;
return
;
}
var
_table_markup
=
horRuler
.
m_oTableMarkup
;
this
.
HtmlPage
.
CheckShowOverlay
();
var
_epsRects
=
this
.
TableRulersRectOffset
;
var
_rectWidth
=
this
.
TableRulersRectSize
;
var
ctx
=
overlay
.
m_oContext
;
ctx
.
fillStyle
=
"
#F0F0F0
"
;
ctx
.
strokeStyle
=
"
#000000
"
;
ctx
.
lineWidth
=
1
;
var
_tableW
=
0
;
var
_cols
=
_table_markup
.
Cols
;
for
(
var
i
=
0
;
i
<
_cols
.
length
;
i
++
)
{
_tableW
+=
_cols
[
i
];
}
if
(
!
_table_outline_dr
.
TableMatrix
||
AscCommon
.
global_MatrixTransformer
.
IsIdentity
(
_table_outline_dr
.
TableMatrix
))
{
this
.
TableMovePoint
=
{
X
:
_tableOutline
.
X
,
Y
:
_tableOutline
.
Y
};
var
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
,
_tableOutline
.
Y
,
_tableOutline
.
PageNum
);
var
pos2
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
+
_tableW
,
_tableOutline
.
Y
,
_tableOutline
.
PageNum
);
ctx
.
beginPath
();
var
TableMoveRect_x
=
(
pos1
.
X
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
var
TableMoveRect_y
=
(
pos1
.
Y
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
overlay
.
AddRect
(
TableMoveRect_x
,
TableMoveRect_y
,
_rectWidth
,
_rectWidth
);
overlay
.
AddRect
((
pos1
.
X
>>
0
)
+
0.5
,
TableMoveRect_y
,
(
pos2
.
X
-
pos1
.
X
)
>>
0
,
_rectWidth
);
var
_count
=
_table_markup
.
Rows
.
length
;
var
_y1
=
0
;
var
_y2
=
0
;
for
(
var
i
=
0
;
i
<
_count
;
i
++
)
{
if
(
i
==
0
)
_y1
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
+=
_table_markup
.
Rows
[
i
].
H
;
}
var
pos3
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
,
_y1
,
this
.
DrawingDocument
.
m_lCurrentPage
);
var
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
,
_y2
,
this
.
DrawingDocument
.
m_lCurrentPage
);
overlay
.
AddRect
((
pos1
.
X
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
),
(
pos3
.
Y
>>
0
)
+
0.5
,
_rectWidth
,
(
pos4
.
Y
-
pos3
.
Y
)
>>
0
);
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
#FFFFFF
"
;
ctx
.
strokeStyle
=
"
#0000FF
"
;
var
dKoef
=
(
this
.
HtmlPage
.
m_nZoomValue
*
AscCommon
.
g_dKoef_mm_to_pix
/
100
);
var
xDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
left
;
var
yDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
top
;
var
_oldY
=
_table_markup
.
Rows
[
0
].
Y
+
_table_markup
.
Rows
[
0
].
H
;
this
.
TableVerRulerPoints
=
[];
var
_rectIndex
=
0
;
var
_x
=
(
pos1
.
X
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
for
(
var
i
=
1
;
i
<=
_count
;
i
++
)
{
var
_newPos
=
(
i
!=
_count
)
?
_table_markup
.
Rows
[
i
].
Y
:
_oldY
;
var
_p
=
{
Y
:
_oldY
,
H
:
(
_newPos
-
_oldY
)
};
var
_r_x
=
_x
;
var
_r_y
=
((
yDst
+
dKoef
*
_oldY
)
>>
0
)
+
0.5
;
var
_r_h
=
((
_newPos
-
_oldY
)
*
dKoef
)
>>
0
;
overlay
.
AddRect
(
_r_x
,
_r_y
,
_rectWidth
,
_r_h
);
this
.
TableVerRulerPoints
[
_rectIndex
++
]
=
_p
;
if
(
i
!=
_count
)
_oldY
=
_table_markup
.
Rows
[
i
].
Y
+
_table_markup
.
Rows
[
i
].
H
;
}
this
.
TableHorRulerPoints
=
[];
_rectIndex
=
0
;
var
_col
=
_table_markup
.
X
;
for
(
var
i
=
1
;
i
<=
_cols
.
length
;
i
++
)
{
_col
+=
_cols
[
i
-
1
];
var
_x
=
_col
-
_table_markup
.
Margins
[
i
-
1
].
Right
;
var
_r
=
_col
+
((
i
==
_cols
.
length
)
?
0
:
_table_markup
.
Margins
[
i
].
Left
);
var
__x
=
((
xDst
+
dKoef
*
_x
)
>>
0
)
+
0.5
;
var
__r
=
((
xDst
+
dKoef
*
_r
)
>>
0
)
+
0.5
;
overlay
.
AddRect
(
__x
,
TableMoveRect_y
,
__r
-
__x
,
_rectWidth
);
this
.
TableHorRulerPoints
[
_rectIndex
++
]
=
{
X
:
_x
,
W
:
_r
-
_x
,
C
:
_col
};
}
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
if
(
this
.
Mode
==
MobileTouchMode
.
TableRuler
)
{
if
(
0
==
this
.
TableCurrentMoveDir
)
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
TableCurrentMoveValue
,
0
,
_table_outline_dr
.
CurrentPageIndex
);
overlay
.
VertLine
(
_pos
.
X
,
true
);
}
else
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
0
,
this
.
TableCurrentMoveValue
,
_table_outline_dr
.
CurrentPageIndex
);
overlay
.
HorLine
(
_pos
.
Y
,
true
);
}
}
}
else
{
var
dKoef
=
(
this
.
HtmlPage
.
m_nZoomValue
*
AscCommon
.
g_dKoef_mm_to_pix
/
100
);
var
xDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
left
;
var
yDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
top
;
ctx
.
lineWidth
=
1
/
dKoef
;
var
_coord_transform
=
new
AscCommon
.
CMatrix
();
_coord_transform
.
sx
=
dKoef
;
_coord_transform
.
sy
=
dKoef
;
_coord_transform
.
tx
=
xDst
;
_coord_transform
.
ty
=
yDst
;
_coord_transform
.
Multiply
(
_table_outline_dr
.
TableMatrix
,
MATRIX_ORDER_PREPEND
);
ctx
.
setTransform
(
_coord_transform
.
sx
,
_coord_transform
.
shy
,
_coord_transform
.
shx
,
_coord_transform
.
sy
,
_coord_transform
.
tx
,
_coord_transform
.
ty
);
this
.
TableMovePoint
=
{
X
:
_tableOutline
.
X
,
Y
:
_tableOutline
.
Y
};
ctx
.
beginPath
();
var
_rectW
=
_rectWidth
/
dKoef
;
var
_offset
=
(
_epsRects
+
_rectWidth
)
/
dKoef
;
ctx
.
rect
(
this
.
TableMovePoint
.
X
-
_offset
,
this
.
TableMovePoint
.
Y
-
_offset
,
_rectW
,
_rectW
);
ctx
.
rect
(
this
.
TableMovePoint
.
X
,
this
.
TableMovePoint
.
Y
-
_offset
,
_tableW
,
_rectW
);
var
_count
=
_table_markup
.
Rows
.
length
;
var
_y1
=
0
;
var
_y2
=
0
;
for
(
var
i
=
0
;
i
<
_count
;
i
++
)
{
if
(
i
==
0
)
_y1
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
+=
_table_markup
.
Rows
[
i
].
H
;
}
ctx
.
rect
(
this
.
TableMovePoint
.
X
-
_offset
,
this
.
TableMovePoint
.
Y
,
_rectW
,
_y2
-
_y1
);
overlay
.
CheckRectT
(
this
.
TableMovePoint
.
X
,
this
.
TableMovePoint
.
Y
,
_tableW
,
_y2
-
_y1
,
_coord_transform
,
2
*
(
_epsRects
+
_rectWidth
));
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
ctx
.
fillStyle
=
"
#FFFFFF
"
;
ctx
.
strokeStyle
=
"
#0000FF
"
;
var
_oldY
=
_table_markup
.
Rows
[
0
].
Y
+
_table_markup
.
Rows
[
0
].
H
;
_oldY
-=
_table_outline_dr
.
TableMatrix
.
ty
;
this
.
TableVerRulerPoints
=
[];
var
_rectIndex
=
0
;
var
_xx
=
this
.
TableMovePoint
.
X
-
_offset
;
for
(
var
i
=
1
;
i
<=
_count
;
i
++
)
{
var
_newPos
=
(
i
!=
_count
)
?
(
_table_markup
.
Rows
[
i
].
Y
-
_table_outline_dr
.
TableMatrix
.
ty
)
:
_oldY
;
var
_p
=
{
Y
:
_oldY
,
H
:
(
_newPos
-
_oldY
)
};
ctx
.
rect
(
_xx
,
_p
.
Y
,
_rectW
,
_p
.
H
);
this
.
TableVerRulerPoints
[
_rectIndex
++
]
=
_p
;
if
(
i
!=
_count
)
{
_oldY
=
_table_markup
.
Rows
[
i
].
Y
+
_table_markup
.
Rows
[
i
].
H
;
_oldY
-=
_table_outline_dr
.
TableMatrix
.
ty
;
}
}
this
.
TableHorRulerPoints
=
[];
_rectIndex
=
0
;
var
_col
=
this
.
TableMovePoint
.
X
;
for
(
var
i
=
1
;
i
<=
_cols
.
length
;
i
++
)
{
_col
+=
_cols
[
i
-
1
];
var
_x
=
_col
-
_table_markup
.
Margins
[
i
-
1
].
Right
;
var
_r
=
_col
+
((
i
==
_cols
.
length
)
?
0
:
_table_markup
.
Margins
[
i
].
Left
);
ctx
.
rect
(
_x
,
this
.
TableMovePoint
.
Y
-
_offset
,
_r
-
_x
,
_rectW
);
this
.
TableHorRulerPoints
[
_rectIndex
++
]
=
{
X
:
_x
,
W
:
_r
-
_x
,
C
:
_col
};
}
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
);
ctx
.
beginPath
();
if
(
this
.
Mode
==
MobileTouchMode
.
TableRuler
)
{
if
(
0
==
this
.
TableCurrentMoveDir
)
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
TableCurrentMoveValue
,
0
,
_table_outline_dr
.
CurrentPageIndex
,
_table_outline_dr
.
TableMatrix
);
overlay
.
VertLine
(
_pos
.
X
,
true
);
}
else
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
0
,
this
.
TableCurrentMoveValue
,
_table_outline_dr
.
CurrentPageIndex
,
_table_outline_dr
.
TableMatrix
);
overlay
.
HorLine
(
_pos
.
Y
,
true
);
}
}
}
};
CMobileTouchManager
.
prototype
.
CheckTableRules2
=
function
(
overlay
)
{
if
(
this
.
HtmlPage
.
m_oApi
.
isViewMode
)
return
;
var
horRuler
=
this
.
HtmlPage
.
m_oHorRuler
;
var
verRuler
=
this
.
HtmlPage
.
m_oVerRuler
;
var
_table_outline_dr
=
this
.
DrawingDocument
.
TableOutlineDr
;
var
_tableOutline
=
_table_outline_dr
.
TableOutline
;
if
(
horRuler
.
CurrentObjectType
!=
RULER_OBJECT_TYPE_TABLE
||
verRuler
.
CurrentObjectType
!=
RULER_OBJECT_TYPE_TABLE
||
!
_tableOutline
)
{
this
.
TableMovePoint
=
null
;
this
.
TableHorRulerPoints
=
null
;
this
.
TableVerRulerPoints
=
null
;
return
;
}
if
(
!
window
.
g_table_track_mobile_move
.
asc_complete
||
!
window
.
g_table_track_round
.
asc_complete
||
!
window
.
g_table_track_diamond
.
asc_complete
)
return
;
var
_table_markup
=
horRuler
.
m_oTableMarkup
;
this
.
HtmlPage
.
CheckShowOverlay
();
var
_epsRects
=
this
.
TableRulersRectOffset
;
var
_rectWidth
=
this
.
TableRulersRectSize
;
var
ctx
=
overlay
.
m_oContext
;
ctx
.
strokeStyle
=
"
#616161
"
;
ctx
.
lineWidth
=
1
;
var
_tableW
=
0
;
var
_cols
=
_table_markup
.
Cols
;
for
(
var
i
=
0
;
i
<
_cols
.
length
;
i
++
)
{
_tableW
+=
_cols
[
i
];
}
if
(
!
_table_outline_dr
.
TableMatrix
||
AscCommon
.
global_MatrixTransformer
.
IsIdentity
(
_table_outline_dr
.
TableMatrix
))
{
this
.
TableMovePoint
=
{
X
:
_tableOutline
.
X
,
Y
:
_tableOutline
.
Y
};
var
pos1
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
,
_tableOutline
.
Y
,
_tableOutline
.
PageNum
);
var
pos2
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
+
_tableW
,
_tableOutline
.
Y
,
_tableOutline
.
PageNum
);
ctx
.
beginPath
();
var
TableMoveRect_x
=
(
pos1
.
X
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
var
TableMoveRect_y
=
(
pos1
.
Y
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
overlay
.
CheckPoint
(
TableMoveRect_x
,
TableMoveRect_y
);
overlay
.
CheckPoint
(
TableMoveRect_x
+
_rectWidth
,
TableMoveRect_y
+
_rectWidth
);
ctx
.
drawImage
(
window
.
g_table_track_mobile_move
,
TableMoveRect_x
,
TableMoveRect_y
);
var
gradObj
=
ctx
.
createLinearGradient
((
pos1
.
X
>>
0
)
+
0.5
,
TableMoveRect_y
,
(
pos1
.
X
>>
0
)
+
0.5
,
TableMoveRect_y
+
_rectWidth
);
gradObj
.
addColorStop
(
0
,
"
#f1f1f1
"
);
gradObj
.
addColorStop
(
1
,
"
#dfdfdf
"
);
ctx
.
fillStyle
=
gradObj
;
overlay
.
AddRoundRect
((
pos1
.
X
>>
0
)
+
0.5
,
TableMoveRect_y
,
(
pos2
.
X
-
pos1
.
X
)
>>
0
,
_rectWidth
,
4
);
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
var
_count
=
_table_markup
.
Rows
.
length
;
var
_y1
=
0
;
var
_y2
=
0
;
for
(
var
i
=
0
;
i
<
_count
;
i
++
)
{
if
(
i
==
0
)
_y1
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
+=
_table_markup
.
Rows
[
i
].
H
;
}
var
pos3
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
,
_y1
,
this
.
DrawingDocument
.
m_lCurrentPage
);
var
pos4
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
_tableOutline
.
X
,
_y2
,
this
.
DrawingDocument
.
m_lCurrentPage
);
var
_ttX
=
(
pos1
.
X
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
gradObj
=
ctx
.
createLinearGradient
(
_ttX
,
(
pos3
.
Y
>>
0
)
+
0.5
,
_ttX
,
(
pos3
.
Y
>>
0
)
+
0.5
+
(
pos4
.
Y
-
pos3
.
Y
)
>>
0
);
gradObj
.
addColorStop
(
0
,
"
#f1f1f1
"
);
gradObj
.
addColorStop
(
1
,
"
#dfdfdf
"
);
ctx
.
fillStyle
=
gradObj
;
overlay
.
AddRoundRect
((
pos1
.
X
>>
0
)
+
1.5
-
(
_epsRects
+
_rectWidth
),
(
pos3
.
Y
>>
0
)
+
0.5
,
_rectWidth
-
1
,
(
pos4
.
Y
-
pos3
.
Y
)
>>
0
,
4
);
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
var
___w
=
window
.
g_table_track_diamond
.
width
;
var
___h
=
window
.
g_table_track_diamond
.
height
;
var
dKoef
=
(
this
.
HtmlPage
.
m_nZoomValue
*
AscCommon
.
g_dKoef_mm_to_pix
/
100
);
var
xDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
left
;
var
yDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
top
;
var
_oldY
=
_table_markup
.
Rows
[
0
].
Y
+
_table_markup
.
Rows
[
0
].
H
;
this
.
TableVerRulerPoints
=
[];
var
_rectIndex
=
0
;
var
_x
=
(
pos1
.
X
>>
0
)
+
0.5
-
(
_epsRects
+
_rectWidth
);
for
(
var
i
=
1
;
i
<=
_count
;
i
++
)
{
var
_newPos
=
(
i
!=
_count
)
?
_table_markup
.
Rows
[
i
].
Y
:
_oldY
;
var
_p
=
{
Y
:
_oldY
,
H
:
(
_newPos
-
_oldY
)
};
var
_r_x
=
_x
;
var
_r_y
=
((
yDst
+
dKoef
*
_oldY
)
>>
0
)
+
0.5
;
var
_r_h
=
((
_newPos
-
_oldY
)
*
dKoef
)
>>
0
;
var
xImage
=
(
_r_x
+
1
)
>>
0
;
var
yImage
=
(
_r_y
+
(
_r_h
/
2
)
-
(
___h
/
2
))
>>
0
;
overlay
.
CheckRect
(
xImage
,
yImage
,
___w
,
___h
);
ctx
.
drawImage
(
window
.
g_table_track_diamond
,
xImage
,
yImage
);
this
.
TableVerRulerPoints
[
_rectIndex
++
]
=
_p
;
if
(
i
!=
_count
)
_oldY
=
_table_markup
.
Rows
[
i
].
Y
+
_table_markup
.
Rows
[
i
].
H
;
}
this
.
TableHorRulerPoints
=
[];
_rectIndex
=
0
;
var
_col
=
_table_markup
.
X
;
for
(
var
i
=
1
;
i
<=
_cols
.
length
;
i
++
)
{
_col
+=
_cols
[
i
-
1
];
var
_x
=
_col
-
_table_markup
.
Margins
[
i
-
1
].
Right
;
var
_r
=
_col
+
((
i
==
_cols
.
length
)
?
0
:
_table_markup
.
Margins
[
i
].
Left
);
var
__x
=
((
xDst
+
dKoef
*
_x
)
>>
0
)
+
0.5
;
var
__r
=
((
xDst
+
dKoef
*
_r
)
>>
0
)
+
0.5
;
var
__c
=
((
xDst
+
dKoef
*
_col
)
>>
0
)
+
0.5
;
var
xImage
=
(
__c
-
(
___w
/
2
))
>>
0
;
var
yImage
=
(
TableMoveRect_y
+
1
)
>>
0
;
overlay
.
CheckRect
(
xImage
,
yImage
,
___w
,
___h
);
ctx
.
drawImage
(
window
.
g_table_track_diamond
,
xImage
,
yImage
);
this
.
TableHorRulerPoints
[
_rectIndex
++
]
=
{
X
:
_x
,
W
:
_r
-
_x
,
C
:
_col
};
}
ctx
.
beginPath
();
if
(
this
.
Mode
==
MobileTouchMode
.
TableRuler
)
{
if
(
0
==
this
.
TableCurrentMoveDir
)
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
TableCurrentMoveValue
,
0
,
_table_outline_dr
.
CurrentPageIndex
);
overlay
.
VertLine
(
_pos
.
X
,
true
);
}
else
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
0
,
this
.
TableCurrentMoveValue
,
_table_outline_dr
.
CurrentPageIndex
);
overlay
.
HorLine
(
_pos
.
Y
,
true
);
}
}
}
else
{
var
dKoef
=
(
this
.
HtmlPage
.
m_nZoomValue
*
AscCommon
.
g_dKoef_mm_to_pix
/
100
);
var
xDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
left
;
var
yDst
=
this
.
DrawingDocument
.
m_arrPages
[
this
.
DrawingDocument
.
m_lCurrentPage
].
drawingPage
.
top
;
ctx
.
lineWidth
=
1
/
dKoef
;
var
_coord_transform
=
new
AscCommon
.
CMatrix
();
_coord_transform
.
sx
=
dKoef
;
_coord_transform
.
sy
=
dKoef
;
_coord_transform
.
tx
=
xDst
;
_coord_transform
.
ty
=
yDst
;
_coord_transform
.
Multiply
(
_table_outline_dr
.
TableMatrix
,
MATRIX_ORDER_PREPEND
);
ctx
.
setTransform
(
_coord_transform
.
sx
,
_coord_transform
.
shy
,
_coord_transform
.
shx
,
_coord_transform
.
sy
,
_coord_transform
.
tx
,
_coord_transform
.
ty
);
this
.
TableMovePoint
=
{
X
:
_tableOutline
.
X
,
Y
:
_tableOutline
.
Y
};
ctx
.
beginPath
();
var
_rectW
=
_rectWidth
/
dKoef
;
var
_offset
=
(
_epsRects
+
_rectWidth
)
/
dKoef
;
ctx
.
drawImage
(
window
.
g_table_track_mobile_move
,
this
.
TableMovePoint
.
X
-
_offset
,
this
.
TableMovePoint
.
Y
-
_offset
,
_rectW
,
_rectW
);
var
gradObj
=
ctx
.
createLinearGradient
(
this
.
TableMovePoint
.
X
,
this
.
TableMovePoint
.
Y
-
_offset
,
this
.
TableMovePoint
.
X
,
this
.
TableMovePoint
.
Y
-
_offset
+
_rectW
);
gradObj
.
addColorStop
(
0
,
"
#f1f1f1
"
);
gradObj
.
addColorStop
(
1
,
"
#dfdfdf
"
);
ctx
.
fillStyle
=
gradObj
;
overlay
.
AddRoundRectCtx
(
ctx
,
this
.
TableMovePoint
.
X
,
this
.
TableMovePoint
.
Y
-
_offset
,
_tableW
,
_rectW
,
5
/
dKoef
);
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
var
_count
=
_table_markup
.
Rows
.
length
;
var
_y1
=
0
;
var
_y2
=
0
;
for
(
var
i
=
0
;
i
<
_count
;
i
++
)
{
if
(
i
==
0
)
_y1
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
=
_table_markup
.
Rows
[
i
].
Y
;
_y2
+=
_table_markup
.
Rows
[
i
].
H
;
}
gradObj
=
ctx
.
createLinearGradient
(
this
.
TableMovePoint
.
X
-
_offset
,
this
.
TableMovePoint
.
Y
,
this
.
TableMovePoint
.
X
-
_offset
,
this
.
TableMovePoint
.
X
-
_offset
+
_y2
-
_y1
);
gradObj
.
addColorStop
(
0
,
"
#f1f1f1
"
);
gradObj
.
addColorStop
(
1
,
"
#dfdfdf
"
);
ctx
.
fillStyle
=
gradObj
;
overlay
.
AddRoundRectCtx
(
ctx
,
this
.
TableMovePoint
.
X
-
_offset
,
this
.
TableMovePoint
.
Y
,
_rectW
,
_y2
-
_y1
,
5
/
dKoef
);
overlay
.
CheckRectT
(
this
.
TableMovePoint
.
X
,
this
.
TableMovePoint
.
Y
,
_tableW
,
_y2
-
_y1
,
_coord_transform
,
2
*
(
_epsRects
+
_rectWidth
));
ctx
.
fill
();
ctx
.
stroke
();
ctx
.
beginPath
();
var
_oldY
=
_table_markup
.
Rows
[
0
].
Y
+
_table_markup
.
Rows
[
0
].
H
;
_oldY
-=
_table_outline_dr
.
TableMatrix
.
ty
;
var
___w
=
window
.
g_table_track_diamond
.
width
;
var
___h
=
window
.
g_table_track_diamond
.
height
;
this
.
TableVerRulerPoints
=
[];
var
_rectIndex
=
0
;
var
_xx
=
this
.
TableMovePoint
.
X
-
_offset
;
for
(
var
i
=
1
;
i
<=
_count
;
i
++
)
{
var
_newPos
=
(
i
!=
_count
)
?
(
_table_markup
.
Rows
[
i
].
Y
-
_table_outline_dr
.
TableMatrix
.
ty
)
:
_oldY
;
var
_p
=
{
Y
:
_oldY
,
H
:
(
_newPos
-
_oldY
)
};
var
___y
=
(
_p
.
Y
+
(
_p
.
H
/
2
)
-
((
___h
/
dKoef
)
/
2
));
ctx
.
drawImage
(
window
.
g_table_track_diamond
,
_xx
,
___y
,
___w
/
dKoef
,
___h
/
dKoef
);
this
.
TableVerRulerPoints
[
_rectIndex
++
]
=
_p
;
if
(
i
!=
_count
)
{
_oldY
=
_table_markup
.
Rows
[
i
].
Y
+
_table_markup
.
Rows
[
i
].
H
;
_oldY
-=
_table_outline_dr
.
TableMatrix
.
ty
;
}
}
this
.
TableHorRulerPoints
=
[];
_rectIndex
=
0
;
var
_col
=
this
.
TableMovePoint
.
X
;
for
(
var
i
=
1
;
i
<=
_cols
.
length
;
i
++
)
{
_col
+=
_cols
[
i
-
1
];
var
_x
=
_col
-
_table_markup
.
Margins
[
i
-
1
].
Right
;
var
_r
=
_col
+
((
i
==
_cols
.
length
)
?
0
:
_table_markup
.
Margins
[
i
].
Left
);
var
___x
=
(
_col
-
((
___w
/
dKoef
)
/
2
));
ctx
.
drawImage
(
window
.
g_table_track_diamond
,
___x
,
(
this
.
TableMovePoint
.
Y
-
_offset
),
___w
/
dKoef
,
___h
/
dKoef
);
this
.
TableHorRulerPoints
[
_rectIndex
++
]
=
{
X
:
_x
,
W
:
_r
-
_x
,
C
:
_col
};
}
ctx
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
);
ctx
.
beginPath
();
if
(
this
.
Mode
==
MobileTouchMode
.
TableRuler
)
{
if
(
0
==
this
.
TableCurrentMoveDir
)
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
this
.
TableCurrentMoveValue
,
0
,
_table_outline_dr
.
CurrentPageIndex
,
_table_outline_dr
.
TableMatrix
);
overlay
.
VertLine
(
_pos
.
X
,
true
);
}
else
{
var
_pos
=
this
.
DrawingDocument
.
ConvertCoordsToCursorWR
(
0
,
this
.
TableCurrentMoveValue
,
_table_outline_dr
.
CurrentPageIndex
,
_table_outline_dr
.
TableMatrix
);
overlay
.
HorLine
(
_pos
.
Y
,
true
);
}
}
}
};
//------------------------------------------------------------export---------------------------------------------------
window
[
'
AscCommonExcel
'
]
=
window
[
'
AscCommonExcel
'
]
||
{};
window
[
'
AscCommonExcel
'
].
CMobileTouchManager
=
CMobileTouchManager
;
})(
window
);
})(
window
);
common/Drawings/WorkEvents.js
View file @
ae3cf693
...
@@ -842,6 +842,7 @@
...
@@ -842,6 +842,7 @@
this
.
LogicDocument
=
null
;
this
.
LogicDocument
=
null
;
this
.
DrawingDocument
=
null
;
this
.
DrawingDocument
=
null
;
this
.
HtmlPage
=
null
;
this
.
HtmlPage
=
null
;
this
.
Api
=
null
;
this
.
Mode
=
0
;
this
.
Mode
=
0
;
this
.
IsTouching
=
false
;
this
.
IsTouching
=
false
;
...
@@ -892,17 +893,62 @@
...
@@ -892,17 +893,62 @@
this
.
ContextMenuLastModeCounter
=
0
;
this
.
ContextMenuLastModeCounter
=
0
;
this
.
ContextMenuShowTimerId
=
-
1
;
this
.
ContextMenuShowTimerId
=
-
1
;
this
.
CreateScrollerDiv
=
function
(
_wrapper
,
_id
)
{
var
_scroller
=
document
.
createElement
(
'
div
'
);
var
_style
=
"
position: absolute; z-index: 0; margin: 0; padding: 0; -webkit-tap-highlight-color: rgba(0,0,0,0); width: 100%; heigth: 100%; display: block;
"
;
_style
+=
"
-webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0);
"
;
_style
+=
"
-webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
"
;
_style
+=
"
-webkit-text-size-adjust: none; -moz-text-size-adjust: none; -ms-text-size-adjust: none; -o-text-size-adjust: none; text-size-adjust: none;
"
;
_scroller
.
style
=
_style
;
_scroller
.
id
=
_id
;
_wrapper
.
appendChild
(
_scroller
);
};
this
.
Init
=
function
(
ctrl
)
this
.
Init
=
function
(
ctrl
)
{
{
this
.
HtmlPage
=
ctrl
;
this
.
HtmlPage
=
ctrl
;
this
.
LogicDocument
=
ctrl
.
m_oLogicDocument
;
this
.
LogicDocument
=
ctrl
.
m_oLogicDocument
;
this
.
DrawingDocument
=
ctrl
.
m_oDrawingDocument
;
this
.
DrawingDocument
=
ctrl
.
m_oDrawingDocument
;
this
.
Api
=
this
.
HtmlPage
.
m_oApi
;
this
.
CreateScrollerDiv
(
this
.
HtmlPage
.
m_oMainView
.
HtmlElement
,
"
mobile_scroller_id
"
);
this
.
iScroll
=
new
window
.
IScroll
(
this
.
HtmlPage
.
m_oMainView
.
HtmlElement
,
{
scrollbars
:
true
,
mouseWheel
:
true
,
interactiveScrollbars
:
true
,
shrinkScrollbars
:
'
scale
'
,
fadeScrollbars
:
true
,
scrollX
:
true
,
scroller_id
:
"
mobile_scroller_id
"
,
bounce
:
false
});
this
.
iScroll
.
manager
=
this
;
this
.
iScroll
=
new
AscCommon
.
CTouchScroll
(
ctrl
,
{
this
.
iScroll
.
on
(
'
scroll
'
,
function
()
onAnimationEnd
:
function
(
param
)
{
this
.
manager
.
HtmlPage
.
NoneRepaintPages
=
(
true
===
this
.
isAnimating
)
?
true
:
false
;
if
(
this
.
directionLocked
==
"
v
"
)
{
{
param
.
api
.
MobileTouchManager
.
OnScrollAnimationEnd
(
);
this
.
manager
.
HtmlPage
.
m_oScrollVerApi
.
scrollToY
(
-
this
.
y
);
}
}
else
if
(
this
.
directionLocked
==
"
h
"
)
{
this
.
manager
.
HtmlPage
.
m_oScrollHorApi
.
scrollToX
(
-
this
.
x
);
}
else
if
(
this
.
directionLocked
==
"
n
"
)
{
this
.
manager
.
HtmlPage
.
m_oScrollHorApi
.
scrollToX
(
-
this
.
x
);
this
.
manager
.
HtmlPage
.
m_oScrollVerApi
.
scrollToY
(
-
this
.
y
);
}
});
this
.
iScroll
.
on
(
'
scrollEnd
'
,
function
()
{
this
.
manager
.
HtmlPage
.
NoneRepaintPages
=
(
true
===
this
.
isAnimating
)
?
true
:
false
;
this
.
manager
.
OnScrollAnimationEnd
();
this
.
manager
.
HtmlPage
.
OnScroll
();
});
});
LoadMobileImages
();
LoadMobileImages
();
...
@@ -931,7 +977,7 @@
...
@@ -931,7 +977,7 @@
if
(
this
.
IsTouching
)
if
(
this
.
IsTouching
)
return
true
;
return
true
;
if
(
this
.
iScroll
&&
this
.
iScroll
.
a
nimating
)
if
(
this
.
iScroll
&&
this
.
iScroll
.
isA
nimating
)
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -1798,9 +1844,6 @@
...
@@ -1798,9 +1844,6 @@
break
;
break
;
}
}
this
.
iScroll
.
_scrollbar
(
'
h
'
);
this
.
iScroll
.
_scrollbar
(
'
v
'
);
if
(
this
.
HtmlPage
.
m_oApi
.
isViewMode
)
if
(
this
.
HtmlPage
.
m_oApi
.
isViewMode
)
{
{
if
(
e
.
preventDefault
)
if
(
e
.
preventDefault
)
...
@@ -1810,7 +1853,7 @@
...
@@ -1810,7 +1853,7 @@
return
false
;
return
false
;
}
}
if
(
!
this
.
iScroll
.
a
nimating
)
if
(
true
!==
this
.
iScroll
.
isA
nimating
)
this
.
CheckContextMenuTouchEnd
(
isCheckContextMenuMode
);
this
.
CheckContextMenuTouchEnd
(
isCheckContextMenuMode
);
};
};
...
@@ -1974,9 +2017,6 @@
...
@@ -1974,9 +2017,6 @@
break
;
break
;
}
}
this
.
iScroll
.
_scrollbar
(
'
h
'
);
this
.
iScroll
.
_scrollbar
(
'
v
'
);
if
(
e
.
preventDefault
)
if
(
e
.
preventDefault
)
e
.
preventDefault
();
e
.
preventDefault
();
else
else
...
@@ -2024,7 +2064,12 @@
...
@@ -2024,7 +2064,12 @@
this
.
Resize
=
function
()
this
.
Resize
=
function
()
{
{
if
(
this
.
iScroll
!=
null
)
if
(
this
.
iScroll
!=
null
)
{
this
.
iScroll
.
scroller
.
style
.
width
=
this
.
HtmlPage
.
m_dDocumentWidth
+
"
px
"
;
this
.
iScroll
.
scroller
.
style
.
height
=
this
.
HtmlPage
.
m_dDocumentHeight
+
"
px
"
;
this
.
iScroll
.
refresh
(
true
);
this
.
iScroll
.
refresh
(
true
);
}
};
};
this
.
SendShowContextMenu
=
function
()
this
.
SendShowContextMenu
=
function
()
...
@@ -2627,6 +2672,15 @@
...
@@ -2627,6 +2672,15 @@
}
}
}
}
};
};
this
.
Destroy
=
function
()
{
var
_scroller
=
document
.
getElementById
(
"
mobile_scroller_id
"
);
this
.
HtmlPage
.
m_oMainView
.
HtmlElement
.
removeChild
(
_scroller
);
if
(
this
.
iScroll
!=
null
)
this
.
iScroll
.
destroy
();
};
}
}
function
CReaderTouchManager
()
function
CReaderTouchManager
()
...
@@ -2643,23 +2697,34 @@
...
@@ -2643,23 +2697,34 @@
this
.
LogicDocument
=
ctrl
.
m_oLogicDocument
;
this
.
LogicDocument
=
ctrl
.
m_oLogicDocument
;
this
.
DrawingDocument
=
ctrl
.
m_oDrawingDocument
;
this
.
DrawingDocument
=
ctrl
.
m_oDrawingDocument
;
this
.
iScroll
=
new
AscCommon
.
CTouchScroll
(
ctrl
,
{
bounce
:
true
},
this
.
HtmlPage
.
ReaderModeDiv
);
this
.
iScroll
=
new
window
.
IScroll
(
this
.
HtmlPage
.
m_oMainView
.
HtmlElement
,
{
scrollbars
:
true
,
mouseWheel
:
true
,
interactiveScrollbars
:
true
,
shrinkScrollbars
:
'
scale
'
,
fadeScrollbars
:
true
,
scrollX
:
true
,
scroller_id
:
"
reader_id
"
,
bounce
:
false
});
this
.
iScroll
.
manager
=
this
;
this
.
HtmlPage
.
m_oApi
.
sendEvent
(
"
asc_onHidePopMenu
"
);
this
.
HtmlPage
.
m_oApi
.
sendEvent
(
"
asc_onHidePopMenu
"
);
}
}
;
this
.
onTouchStart
=
function
(
e
)
this
.
onTouchStart
=
function
(
e
)
{
{
this
.
iScroll
.
_start
(
e
);
this
.
iScroll
.
_start
(
e
);
this
.
bIsLock
=
true
;
this
.
bIsLock
=
true
;
this
.
bIsMoveAfterDown
=
false
;
this
.
bIsMoveAfterDown
=
false
;
}
}
;
this
.
onTouchMove
=
function
(
e
)
this
.
onTouchMove
=
function
(
e
)
{
{
if
(
!
this
.
bIsLock
)
if
(
!
this
.
bIsLock
)
return
;
return
;
this
.
iScroll
.
_move
(
e
);
this
.
iScroll
.
_move
(
e
);
this
.
bIsMoveAfterDown
=
true
;
this
.
bIsMoveAfterDown
=
true
;
}
}
;
this
.
onTouchEnd
=
function
(
e
)
this
.
onTouchEnd
=
function
(
e
)
{
{
this
.
iScroll
.
_end
(
e
);
this
.
iScroll
.
_end
(
e
);
...
@@ -2669,7 +2734,7 @@
...
@@ -2669,7 +2734,7 @@
{
{
this
.
HtmlPage
.
m_oApi
.
sendEvent
(
"
asc_onTapEvent
"
,
e
);
this
.
HtmlPage
.
m_oApi
.
sendEvent
(
"
asc_onTapEvent
"
,
e
);
}
}
}
}
;
this
.
Resize
=
function
()
this
.
Resize
=
function
()
{
{
...
@@ -2677,27 +2742,20 @@
...
@@ -2677,27 +2742,20 @@
this
.
HtmlPage
.
ReaderModeDivWrapper
.
style
.
height
=
this
.
HtmlPage
.
m_oMainView
.
HtmlElement
.
style
.
height
;
this
.
HtmlPage
.
ReaderModeDivWrapper
.
style
.
height
=
this
.
HtmlPage
.
m_oMainView
.
HtmlElement
.
style
.
height
;
if
(
this
.
iScroll
!=
null
)
if
(
this
.
iScroll
!=
null
)
{
this
.
iScroll
.
refresh
();
this
.
iScroll
.
refresh
();
this
.
iScroll
.
_pos
(
this
.
iScroll
.
x
,
this
.
iScroll
.
y
,
false
);
};
}
}
this
.
ChangeFontSize
=
function
()
this
.
ChangeFontSize
=
function
()
{
{
if
(
this
.
iScroll
!=
null
)
if
(
this
.
iScroll
!=
null
)
{
//this.ReaderTouchManager.iScroll._changeMaxes();
this
.
iScroll
.
refresh
();
this
.
iScroll
.
refresh
();
this
.
iScroll
.
_pos
(
this
.
iScroll
.
x
,
this
.
iScroll
.
y
,
false
);
};
}
}
this
.
Destroy
=
function
()
this
.
Destroy
=
function
()
{
{
if
(
this
.
iScroll
!=
null
)
if
(
this
.
iScroll
!=
null
)
this
.
iScroll
.
destroy
();
this
.
iScroll
.
destroy
();
}
}
;
}
}
function
LoadMobileImages
()
function
LoadMobileImages
()
...
...
common/Scrolls/iscroll.js
View file @
ae3cf693
/*!
/*! iScroll v5.2.0 ~ (c) 2008-2016 Matteo Spinelli ~ http://cubiq.org/license */
* iScroll v4.2.5 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
(
function
(
window
,
document
,
Math
)
{
* Released under MIT license, http://cubiq.org/license
var
rAF
=
window
.
requestAnimationFrame
||
*/
window
.
webkitRequestAnimationFrame
||
(
function
(
window
,
doc
){
window
.
mozRequestAnimationFrame
||
var
m
=
Math
,
window
.
oRequestAnimationFrame
||
dummyStyle
=
doc
.
createElement
(
'
div
'
).
style
,
window
.
msRequestAnimationFrame
||
vendor
=
(
function
()
{
function
(
callback
)
{
window
.
setTimeout
(
callback
,
1000
/
60
);
};
var
vendors
=
'
t,webkitT,MozT,msT,OT
'
.
split
(
'
,
'
),
t
,
var
utils
=
(
function
()
{
var
me
=
{};
var
_elementStyle
=
document
.
createElement
(
'
div
'
).
style
;
var
_vendor
=
(
function
()
{
var
vendors
=
[
'
t
'
,
'
webkitT
'
,
'
MozT
'
,
'
msT
'
,
'
OT
'
],
transform
,
i
=
0
,
i
=
0
,
l
=
vendors
.
length
;
l
=
vendors
.
length
;
for
(
;
i
<
l
;
i
++
)
{
for
(
;
i
<
l
;
i
++
)
{
t
=
vendors
[
i
]
+
'
ransform
'
;
transform
=
vendors
[
i
]
+
'
ransform
'
;
if
(
t
in
dummyStyle
)
{
if
(
transform
in
_elementStyle
)
return
vendors
[
i
].
substr
(
0
,
vendors
[
i
].
length
-
1
);
return
vendors
[
i
].
substr
(
0
,
vendors
[
i
].
length
-
1
);
}
}
}
return
false
;
return
false
;
})(),
})();
cssVendor
=
vendor
?
'
-
'
+
vendor
.
toLowerCase
()
+
'
-
'
:
''
,
function
_prefixStyle
(
style
)
{
// Style properties
if
(
_vendor
===
false
)
return
false
;
transform
=
prefixStyle
(
'
transform
'
),
if
(
_vendor
===
''
)
return
style
;
transitionProperty
=
prefixStyle
(
'
transitionProperty
'
),
return
_vendor
+
style
.
charAt
(
0
).
toUpperCase
()
+
style
.
substr
(
1
);
transitionDuration
=
prefixStyle
(
'
transitionDuration
'
),
}
transformOrigin
=
prefixStyle
(
'
transformOrigin
'
),
transitionTimingFunction
=
prefixStyle
(
'
transitionTimingFunction
'
),
me
.
getTime
=
Date
.
now
||
function
getTime
()
{
return
new
Date
().
getTime
();
};
transitionDelay
=
prefixStyle
(
'
transitionDelay
'
),
me
.
extend
=
function
(
target
,
obj
)
{
// Browser capabilities
for
(
var
i
in
obj
)
{
isAndroid
=
(
/android/gi
).
test
(
navigator
.
appVersion
),
target
[
i
]
=
obj
[
i
];
isIDevice
=
(
/iphone|ipad/gi
).
test
(
navigator
.
appVersion
),
}
isTouchPad
=
(
/hp-tablet/gi
).
test
(
navigator
.
appVersion
),
};
has3d
=
prefixStyle
(
'
perspective
'
)
in
dummyStyle
,
me
.
addEvent
=
function
(
el
,
type
,
fn
,
capture
)
{
hasTouch
=
'
ontouchstart
'
in
window
&&
!
isTouchPad
,
el
.
addEventListener
(
type
,
fn
,
!!
capture
);
hasTransform
=
vendor
!==
false
,
};
hasTransitionEnd
=
prefixStyle
(
'
transition
'
)
in
dummyStyle
,
me
.
removeEvent
=
function
(
el
,
type
,
fn
,
capture
)
{
TRNEND_EV
=
(
function
()
{
el
.
removeEventListener
(
type
,
fn
,
!!
capture
);
if
(
vendor
===
false
)
return
false
;
};
var
transitionEnd
=
{
me
.
prefixPointerEvent
=
function
(
pointerEvent
)
{
''
:
'
transitionend
'
,
return
window
.
MSPointerEvent
?
'
webkit
'
:
'
webkitTransitionEnd
'
,
'
MSPointer
'
+
pointerEvent
.
charAt
(
7
).
toUpperCase
()
+
pointerEvent
.
substr
(
8
):
'
Moz
'
:
'
transitionend
'
,
pointerEvent
;
'
O
'
:
'
otransitionend
'
,
};
'
ms
'
:
'
MSTransitionEnd
'
};
me
.
momentum
=
function
(
current
,
start
,
time
,
lowerMargin
,
wrapperSize
,
deceleration
)
{
var
distance
=
current
-
start
,
return
transitionEnd
[
vendor
];
speed
=
Math
.
abs
(
distance
)
/
time
,
})(),
destination
,
duration
;
nextFrame
=
(
function
()
{
return
window
.
requestAnimationFrame
||
deceleration
=
deceleration
===
undefined
?
0.0006
:
deceleration
;
window
.
webkitRequestAnimationFrame
||
window
.
mozRequestAnimationFrame
||
destination
=
current
+
(
speed
*
speed
)
/
(
2
*
deceleration
)
*
(
distance
<
0
?
-
1
:
1
);
window
.
oRequestAnimationFrame
||
duration
=
speed
/
deceleration
;
window
.
msRequestAnimationFrame
||
function
(
callback
)
{
return
setTimeout
(
callback
,
1
);
};
if
(
destination
<
lowerMargin
)
{
})(),
destination
=
wrapperSize
?
lowerMargin
-
(
wrapperSize
/
2.5
*
(
speed
/
8
)
)
:
lowerMargin
;
cancelFrame
=
(
function
()
{
distance
=
Math
.
abs
(
destination
-
current
);
return
window
.
cancelRequestAnimationFrame
||
duration
=
distance
/
speed
;
window
.
webkitCancelAnimationFrame
||
}
else
if
(
destination
>
0
)
{
window
.
webkitCancelRequestAnimationFrame
||
destination
=
wrapperSize
?
wrapperSize
/
2.5
*
(
speed
/
8
)
:
0
;
window
.
mozCancelRequestAnimationFrame
||
distance
=
Math
.
abs
(
current
)
+
destination
;
window
.
oCancelRequestAnimationFrame
||
duration
=
distance
/
speed
;
window
.
msCancelRequestAnimationFrame
||
}
clearTimeout
;
})(),
return
{
destination
:
Math
.
round
(
destination
),
// Helpers
duration
:
duration
translateZ
=
has3d
?
'
translateZ(0)
'
:
''
,
// Constructor
CTouchScroll
=
function
(
api
,
options
,
scroller
)
{
var
that
=
this
,
i
;
that
.
api
=
api
;
that
.
wrapper
=
api
.
m_oMainView
.
HtmlElement
;
that
.
wrapper
.
style
.
overflow
=
'
hidden
'
;
that
.
scroller
=
(
scroller
!==
undefined
)
?
scroller
:
null
;
// Default options
that
.
options
=
{
hScroll
:
true
,
vScroll
:
true
,
x
:
0
,
y
:
0
,
bounce
:
false
,
bounceLock
:
false
,
momentum
:
true
,
lockDirection
:
true
,
useTransform
:
true
,
useTransition
:
false
,
topOffset
:
0
,
checkDOMChanges
:
false
,
// Experimental
handleClick
:
true
,
// Scrollbar
hScrollbar
:
true
,
vScrollbar
:
true
,
fixedScrollbar
:
isAndroid
,
hideScrollbar
:
/*isIDevice*/
true
,
fadeScrollbar
:
isIDevice
&&
has3d
,
scrollbarClass
:
''
,
// Zoom
zoom
:
false
,
zoomMin
:
1
,
zoomMax
:
4
,
doubleTapZoom
:
2
,
wheelAction
:
'
scroll
'
,
// Snap
snap
:
false
,
snapThreshold
:
1
,
// Events
onRefresh
:
null
,
onBeforeScrollStart
:
null
,
onScrollStart
:
null
,
onBeforeScrollMove
:
null
,
onScrollMove
:
null
,
onBeforeScrollEnd
:
null
,
onScrollEnd
:
null
,
onTouchEnd
:
null
,
onDestroy
:
null
,
onZoomStart
:
null
,
onZoom
:
null
,
onZoomEnd
:
null
};
};
};
// User defined options
var
_transform
=
_prefixStyle
(
'
transform
'
);
for
(
i
in
options
)
that
.
options
[
i
]
=
options
[
i
];
me
.
extend
(
me
,
{
// Set starting position
hasTransform
:
_transform
!==
false
,
that
.
x
=
that
.
options
.
x
;
hasPerspective
:
_prefixStyle
(
'
perspective
'
)
in
_elementStyle
,
that
.
y
=
that
.
options
.
y
;
hasTouch
:
'
ontouchstart
'
in
window
,
hasPointer
:
!!
(
window
.
PointerEvent
||
window
.
MSPointerEvent
),
// IE10 is prefixed
// Normalize options
hasTransition
:
_prefixStyle
(
'
transition
'
)
in
_elementStyle
that
.
options
.
useTransform
=
hasTransform
&&
that
.
options
.
useTransform
;
});
that
.
options
.
hScrollbar
=
that
.
options
.
hScroll
&&
that
.
options
.
hScrollbar
;
that
.
options
.
vScrollbar
=
that
.
options
.
vScroll
&&
that
.
options
.
vScrollbar
;
/*
that
.
options
.
zoom
=
that
.
options
.
useTransform
&&
that
.
options
.
zoom
;
This should find all Android browsers lower than build 535.19 (both stock browser and webview)
that
.
options
.
useTransition
=
hasTransitionEnd
&&
that
.
options
.
useTransition
;
- galaxy S2 is ok
- 2.3.6 : `AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1`
// Helpers FIX ANDROID BUG!
- 4.0.4 : `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
// translate3d and scale doesn't work together!
- galaxy S3 is badAndroid (stock brower, webview)
// Ignoring 3d ONLY WHEN YOU SET that.options.zoom
`AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
if
(
that
.
options
.
zoom
&&
isAndroid
){
- galaxy S4 is badAndroid (stock brower, webview)
translateZ
=
''
;
`AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
- galaxy S5 is OK
`AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
- galaxy S6 is OK
`AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
*/
me
.
isBadAndroid
=
(
function
()
{
var
appVersion
=
window
.
navigator
.
appVersion
;
// Android browser is not a chrome browser.
if
(
/Android/
.
test
(
appVersion
)
&&
!
(
/Chrome
\/\d
/
.
test
(
appVersion
)))
{
var
safariVersion
=
appVersion
.
match
(
/Safari
\/(\d
+.
\d)
/
);
if
(
safariVersion
&&
typeof
safariVersion
===
"
object
"
&&
safariVersion
.
length
>=
2
)
{
return
parseFloat
(
safariVersion
[
1
])
<
535.19
;
}
else
{
return
true
;
}
}
else
{
return
false
;
}
}
})();
// Set some default styles
if
(
that
.
scroller
)
me
.
extend
(
me
.
style
=
{},
{
{
transform
:
_transform
,
that
.
scroller
.
style
[
transitionProperty
]
=
that
.
options
.
useTransform
?
cssVendor
+
'
transform
'
:
'
top left
'
;
transitionTimingFunction
:
_prefixStyle
(
'
transitionTimingFunction
'
),
that
.
scroller
.
style
[
transitionDuration
]
=
'
0
'
;
transitionDuration
:
_prefixStyle
(
'
transitionDuration
'
),
that
.
scroller
.
style
[
transformOrigin
]
=
'
0 0
'
;
transitionDelay
:
_prefixStyle
(
'
transitionDelay
'
),
if
(
that
.
options
.
useTransition
)
transformOrigin
:
_prefixStyle
(
'
transformOrigin
'
)
that
.
scroller
.
style
[
transitionTimingFunction
]
=
'
cubic-bezier(0.33,0.66,0.66,1)
'
;
});
if
(
that
.
options
.
useTransform
)
me
.
hasClass
=
function
(
e
,
c
)
{
that
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
that
.
x
+
'
px,
'
+
that
.
y
+
'
px)
'
+
translateZ
;
var
re
=
new
RegExp
(
"
(^|
\\
s)
"
+
c
+
"
(
\\
s|$)
"
);
else
return
re
.
test
(
e
.
className
);
that
.
scroller
.
style
.
cssText
+=
'
;position:absolute;top:
'
+
that
.
y
+
'
px;left:
'
+
that
.
x
+
'
px
'
;
};
me
.
addClass
=
function
(
e
,
c
)
{
if
(
me
.
hasClass
(
e
,
c
)
)
{
return
;
}
}
if
(
that
.
options
.
useTransition
)
that
.
options
.
fixedScrollbar
=
true
;
that
.
refresh
();
var
newclass
=
e
.
className
.
split
(
'
'
);
newclass
.
push
(
c
);
e
.
className
=
newclass
.
join
(
'
'
);
};
};
// Prototype
me
.
removeClass
=
function
(
e
,
c
)
{
CTouchScroll
.
prototype
=
{
if
(
!
me
.
hasClass
(
e
,
c
)
)
{
enabled
:
true
,
return
;
x
:
0
,
y
:
0
,
steps
:
[],
scale
:
1
,
currPageX
:
0
,
currPageY
:
0
,
pagesX
:
[],
pagesY
:
[],
aniTime
:
null
,
wheelZoomCount
:
0
,
handleEvent
:
function
(
e
)
{
var
that
=
this
;
switch
(
e
.
type
)
{
case
TRNEND_EV
:
that
.
_transitionEnd
(
e
);
break
;
}
}
},
_scrollbar
:
function
(
dir
)
{
var
that
=
this
,
bar
;
if
(
dir
==
'
h
'
)
{
if
(
!
that
.
hScrollbar
)
{
if
(
that
.
hScrollbarWrapper
)
{
if
(
hasTransform
)
that
.
hScrollbarIndicator
.
style
[
transform
]
=
''
;
that
.
hScrollbarWrapper
.
parentNode
.
removeChild
(
that
.
hScrollbarWrapper
);
that
.
hScrollbarWrapper
=
null
;
that
.
hScrollbarIndicator
=
null
;
}
return
;
}
if
(
!
that
.
hScrollbarWrapper
)
{
// Create the scrollbar wrapper
bar
=
doc
.
createElement
(
'
div
'
);
if
(
that
.
options
.
scrollbarClass
)
bar
.
className
=
that
.
options
.
scrollbarClass
+
dir
.
toUpperCase
();
else
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;height:7px;bottom:1px;left:2px;right:
'
+
(
that
.
vScrollbar
?
'
7
'
:
'
2
'
)
+
'
px
'
;
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:opacity;
'
+
cssVendor
+
'
transition-duration:
'
+
(
that
.
options
.
fadeScrollbar
?
'
350ms
'
:
'
0
'
)
+
'
;overflow:hidden;opacity:
'
+
(
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
);
that
.
wrapper
.
appendChild
(
bar
);
that
.
hScrollbarWrapper
=
bar
;
// Create the scrollbar indicator
bar
=
doc
.
createElement
(
'
div
'
);
if
(
!
that
.
options
.
scrollbarClass
)
{
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);
'
+
cssVendor
+
'
background-clip:padding-box;
'
+
cssVendor
+
'
box-sizing:border-box;height:100%;
'
+
cssVendor
+
'
border-radius:3px;border-radius:3px
'
;
}
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:
'
+
cssVendor
+
'
transform;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);
'
+
cssVendor
+
'
transition-duration:0;
'
+
cssVendor
+
'
transform: translate(0,0)
'
+
translateZ
;
if
(
that
.
options
.
useTransition
)
bar
.
style
.
cssText
+=
'
;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)
'
;
that
.
hScrollbarWrapper
.
appendChild
(
bar
);
that
.
hScrollbarIndicator
=
bar
;
}
that
.
hScrollbarSize
=
that
.
hScrollbarWrapper
.
clientWidth
;
that
.
hScrollbarIndicatorSize
=
m
.
max
(
m
.
round
(
that
.
hScrollbarSize
*
that
.
hScrollbarSize
/
that
.
scrollerW
),
8
);
that
.
hScrollbarIndicator
.
style
.
width
=
that
.
hScrollbarIndicatorSize
+
'
px
'
;
that
.
hScrollbarMaxScroll
=
that
.
hScrollbarSize
-
that
.
hScrollbarIndicatorSize
;
that
.
hScrollbarProp
=
that
.
hScrollbarMaxScroll
/
that
.
maxScrollX
;
// Reset position
that
.
_scrollbarPos
(
dir
,
true
);
}
else
if
(
dir
==
'
v
'
)
{
if
(
!
that
.
vScrollbar
)
{
if
(
that
.
vScrollbarWrapper
)
{
if
(
hasTransform
)
that
.
vScrollbarIndicator
.
style
[
transform
]
=
''
;
that
.
vScrollbarWrapper
.
parentNode
.
removeChild
(
that
.
vScrollbarWrapper
);
that
.
vScrollbarWrapper
=
null
;
that
.
vScrollbarIndicator
=
null
;
}
return
;
}
if
(
!
that
.
vScrollbarWrapper
)
{
// Create the scrollbar wrapper
bar
=
doc
.
createElement
(
'
div
'
);
if
(
that
.
options
.
scrollbarClass
)
bar
.
className
=
that
.
options
.
scrollbarClass
+
dir
.
toUpperCase
();
else
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;width:7px;bottom:
'
+
(
that
.
hScrollbar
?
'
7
'
:
'
2
'
)
+
'
px;top:2px;right:1px
'
;
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:opacity;
'
+
cssVendor
+
'
transition-duration:
'
+
(
that
.
options
.
fadeScrollbar
?
'
350ms
'
:
'
0
'
)
+
'
;overflow:hidden;opacity:
'
+
(
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
);
that
.
wrapper
.
appendChild
(
bar
);
that
.
vScrollbarWrapper
=
bar
;
// Create the scrollbar indicator
bar
=
doc
.
createElement
(
'
div
'
);
if
(
!
that
.
options
.
scrollbarClass
)
{
bar
.
style
.
cssText
=
'
position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);
'
+
cssVendor
+
'
background-clip:padding-box;
'
+
cssVendor
+
'
box-sizing:border-box;width:100%;
'
+
cssVendor
+
'
border-radius:3px;border-radius:3px
'
;
}
bar
.
style
.
cssText
+=
'
;pointer-events:none;
'
+
cssVendor
+
'
transition-property:
'
+
cssVendor
+
'
transform;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);
'
+
cssVendor
+
'
transition-duration:0;
'
+
cssVendor
+
'
transform: translate(0,0)
'
+
translateZ
;
if
(
that
.
options
.
useTransition
)
bar
.
style
.
cssText
+=
'
;
'
+
cssVendor
+
'
transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)
'
;
that
.
vScrollbarWrapper
.
appendChild
(
bar
);
that
.
vScrollbarIndicator
=
bar
;
}
that
.
vScrollbarSize
=
that
.
vScrollbarWrapper
.
clientHeight
;
that
.
vScrollbarIndicatorSize
=
m
.
max
(
m
.
round
(
that
.
vScrollbarSize
*
that
.
vScrollbarSize
/
that
.
scrollerH
),
8
);
that
.
vScrollbarIndicator
.
style
.
height
=
that
.
vScrollbarIndicatorSize
+
'
px
'
;
that
.
vScrollbarMaxScroll
=
that
.
vScrollbarSize
-
that
.
vScrollbarIndicatorSize
;
that
.
vScrollbarProp
=
that
.
vScrollbarMaxScroll
/
that
.
maxScrollY
;
// Reset position
that
.
_scrollbarPos
(
dir
,
true
);
}
},
_resize
:
function
()
{
var
that
=
this
;
setTimeout
(
function
()
{
that
.
refresh
();
},
isAndroid
?
200
:
0
);
},
_pos
:
function
(
x
,
y
,
isAnim
)
{
if
(
this
.
zoomed
)
return
;
x
=
this
.
hScroll
?
x
:
0
;
var
re
=
new
RegExp
(
"
(^|
\\
s)
"
+
c
+
"
(
\\
s|$)
"
,
'
g
'
);
y
=
this
.
vScroll
?
y
:
0
;
e
.
className
=
e
.
className
.
replace
(
re
,
'
'
);
};
this
.
x
=
x
;
this
.
y
=
y
;
me
.
offset
=
function
(
el
)
{
var
left
=
-
el
.
offsetLeft
,
top
=
-
el
.
offsetTop
;
if
(
isAnim
===
true
)
// jshint -W084
{
while
(
el
=
el
.
offsetParent
)
{
this
.
api
.
NoneRepaintPages
=
true
;
left
-=
el
.
offsetLeft
;
top
-=
el
.
offsetTop
;
}
}
else
// jshint +W084
{
this
.
api
.
NoneRepaintPages
=
false
;
return
{
left
:
left
,
top
:
top
};
};
me
.
preventDefaultException
=
function
(
el
,
exceptions
)
{
for
(
var
i
in
exceptions
)
{
if
(
exceptions
[
i
].
test
(
el
[
i
])
)
{
return
true
;
}
}
}
if
(
this
.
api
.
ReaderModeDiv
==
null
)
return
false
;
{
};
if
(
this
.
hScroll
)
{
me
.
extend
(
me
.
eventType
=
{},
{
this
.
api
.
m_oScrollHorApi
.
scrollToX
(
-
this
.
x
);
touchstart
:
1
,
touchmove
:
1
,
touchend
:
1
,
mousedown
:
2
,
mousemove
:
2
,
mouseup
:
2
,
pointerdown
:
3
,
pointermove
:
3
,
pointerup
:
3
,
MSPointerDown
:
3
,
MSPointerMove
:
3
,
MSPointerUp
:
3
});
me
.
extend
(
me
.
ease
=
{},
{
quadratic
:
{
style
:
'
cubic-bezier(0.25, 0.46, 0.45, 0.94)
'
,
fn
:
function
(
k
)
{
return
k
*
(
2
-
k
);
}
}
if
(
this
.
vScroll
)
},
{
circular
:
{
this
.
api
.
m_oScrollVerApi
.
scrollToY
(
-
this
.
y
);
style
:
'
cubic-bezier(0.1, 0.57, 0.1, 1)
'
,
// Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
fn
:
function
(
k
)
{
return
Math
.
sqrt
(
1
-
(
--
k
*
k
)
);
}
}
}
},
else
if
(
this
.
scroller
)
back
:
{
{
style
:
'
cubic-bezier(0.175, 0.885, 0.32, 1.275)
'
,
if
(
this
.
options
.
useTransform
)
fn
:
function
(
k
)
{
{
var
b
=
4
;
this
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
x
+
'
px,
'
+
y
+
'
px) scale(
'
+
this
.
scale
+
'
)
'
+
translateZ
;
return
(
k
=
k
-
1
)
*
k
*
(
(
b
+
1
)
*
k
+
b
)
+
1
;
}
else
{
x
=
m
.
round
(
x
);
y
=
m
.
round
(
y
);
this
.
scroller
.
style
.
left
=
x
+
'
px
'
;
this
.
scroller
.
style
.
top
=
y
+
'
px
'
;
}
}
}
},
bounce
:
{
this
.
_scrollbarPos
(
'
h
'
);
style
:
''
,
this
.
_scrollbarPos
(
'
v
'
);
fn
:
function
(
k
)
{
},
if
(
(
k
/=
1
)
<
(
1
/
2.75
)
)
{
return
7.5625
*
k
*
k
;
}
else
if
(
k
<
(
2
/
2.75
)
)
{
return
7.5625
*
(
k
-=
(
1.5
/
2.75
)
)
*
k
+
0.75
;
}
else
if
(
k
<
(
2.5
/
2.75
)
)
{
return
7.5625
*
(
k
-=
(
2.25
/
2.75
)
)
*
k
+
0.9375
;
}
else
{
return
7.5625
*
(
k
-=
(
2.625
/
2.75
)
)
*
k
+
0.984375
;
}
}
},
elastic
:
{
style
:
''
,
fn
:
function
(
k
)
{
var
f
=
0.22
,
e
=
0.4
;
_scrollbarPos
:
function
(
dir
,
hidden
)
{
if
(
k
===
0
)
{
return
0
;
}
var
that
=
this
;
if
(
k
==
1
)
{
return
1
;
}
var
size
=
0
;
var
pos
=
that
.
y
;
if
(
dir
==
'
h
'
)
{
pos
=
that
.
x
;
if
(
!
that
.
hScrollbar
)
return
;
pos
=
that
.
hScrollbarProp
*
pos
;
if
(
pos
<
0
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
hScrollbarIndicatorSize
+
m
.
round
(
pos
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
hScrollbarIndicator
.
style
[
'
width
'
]
=
size
+
'
px
'
;
}
pos
=
0
;
}
else
if
(
pos
>
that
.
hScrollbarMaxScroll
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
hScrollbarIndicatorSize
-
m
.
round
((
pos
-
that
.
hScrollbarMaxScroll
)
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
hScrollbarIndicator
.
style
[
'
width
'
]
=
size
+
'
px
'
;
pos
=
that
.
hScrollbarMaxScroll
+
(
that
.
hScrollbarIndicatorSize
-
size
);
}
else
{
pos
=
that
.
hScrollbarMaxScroll
;
}
}
that
.
hScrollbarWrapper
.
style
[
transitionDelay
]
=
'
0
'
;
that
.
hScrollbarWrapper
.
style
.
opacity
=
hidden
&&
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
;
that
.
hScrollbarIndicator
.
style
[
transform
]
=
'
translate(
'
+
pos
+
'
px,0)
'
+
translateZ
;
}
else
{
if
(
!
that
.
vScrollbar
)
return
;
pos
=
that
.
vScrollbarProp
*
pos
;
if
(
pos
<
0
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
vScrollbarIndicatorSize
+
m
.
round
(
pos
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
vScrollbarIndicator
.
style
[
'
height
'
]
=
size
+
'
px
'
;
}
pos
=
0
;
}
else
if
(
pos
>
that
.
vScrollbarMaxScroll
)
{
if
(
!
that
.
options
.
fixedScrollbar
)
{
size
=
that
.
vScrollbarIndicatorSize
-
m
.
round
((
pos
-
that
.
vScrollbarMaxScroll
)
*
3
);
if
(
size
<
8
)
size
=
8
;
that
.
vScrollbarIndicator
.
style
[
'
height
'
]
=
size
+
'
px
'
;
pos
=
that
.
vScrollbarMaxScroll
+
(
that
.
vScrollbarIndicatorSize
-
size
);
}
else
{
pos
=
that
.
vScrollbarMaxScroll
;
}
}
that
.
vScrollbarWrapper
.
style
[
transitionDelay
]
=
'
0
'
;
that
.
vScrollbarWrapper
.
style
.
opacity
=
hidden
&&
that
.
options
.
hideScrollbar
?
'
0
'
:
'
1
'
;
that
.
vScrollbarIndicator
.
style
[
transform
]
=
'
translate(0,
'
+
pos
+
'
px)
'
+
translateZ
;
}
},
_start
:
function
(
e
)
{
var
that
=
this
,
point
=
hasTouch
?
e
.
touches
[
0
]
:
e
,
matrix
,
x
,
y
,
c1
,
c2
;
if
(
!
that
.
enabled
)
return
;
return
(
e
*
Math
.
pow
(
2
,
-
10
*
k
)
*
Math
.
sin
(
(
k
-
f
/
4
)
*
(
2
*
Math
.
PI
)
/
f
)
+
1
);
}
}
});
me
.
tap
=
function
(
e
,
eventName
)
{
var
ev
=
document
.
createEvent
(
'
Event
'
);
ev
.
initEvent
(
eventName
,
true
,
true
);
ev
.
pageX
=
e
.
pageX
;
ev
.
pageY
=
e
.
pageY
;
e
.
target
.
dispatchEvent
(
ev
);
};
if
(
that
.
options
.
onBeforeScrollStart
)
that
.
options
.
onBeforeScrollStart
.
call
(
that
,
e
);
me
.
click
=
function
(
e
)
{
var
target
=
e
.
target
,
ev
;
if
(
!
(
/
(
SELECT|INPUT|TEXTAREA
)
/i
).
test
(
target
.
tagName
)
)
{
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
// initMouseEvent is deprecated.
ev
=
document
.
createEvent
(
window
.
MouseEvent
?
'
MouseEvents
'
:
'
Event
'
);
ev
.
initEvent
(
'
click
'
,
true
,
true
);
ev
.
view
=
e
.
view
||
window
;
ev
.
detail
=
1
;
ev
.
screenX
=
target
.
screenX
||
0
;
ev
.
screenY
=
target
.
screenY
||
0
;
ev
.
clientX
=
target
.
clientX
||
0
;
ev
.
clientY
=
target
.
clientY
||
0
;
ev
.
ctrlKey
=
!!
e
.
ctrlKey
;
ev
.
altKey
=
!!
e
.
altKey
;
ev
.
shiftKey
=
!!
e
.
shiftKey
;
ev
.
metaKey
=
!!
e
.
metaKey
;
ev
.
button
=
0
;
ev
.
relatedTarget
=
null
;
ev
.
_constructed
=
true
;
target
.
dispatchEvent
(
ev
);
}
};
if
(
that
.
options
.
useTransition
||
that
.
options
.
zoom
)
that
.
_transitionTime
(
0
);
return
me
;
})();
function
IScroll
(
el
,
options
)
{
this
.
wrapper
=
typeof
el
==
'
string
'
?
document
.
querySelector
(
el
)
:
el
;
this
.
scroller
=
(
typeof
options
.
scroller_id
==
'
string
'
)
?
document
.
getElementById
(
options
.
scroller_id
)
:
this
.
wrapper
.
children
[
0
];
this
.
scrollerStyle
=
this
.
scroller
.
style
;
// cache style for better performance
that
.
moved
=
false
;
this
.
options
=
{
that
.
animating
=
false
;
that
.
zoomed
=
false
;
that
.
distX
=
0
;
that
.
distY
=
0
;
that
.
absDistX
=
0
;
that
.
absDistY
=
0
;
that
.
dirX
=
0
;
that
.
dirY
=
0
;
// Gesture start
resizeScrollbars
:
true
,
if
(
that
.
options
.
zoom
&&
hasTouch
&&
e
.
touches
.
length
>
1
)
{
c1
=
m
.
abs
(
e
.
touches
[
0
].
pageX
-
e
.
touches
[
1
].
pageX
);
c2
=
m
.
abs
(
e
.
touches
[
0
].
pageY
-
e
.
touches
[
1
].
pageY
);
that
.
touchesDistStart
=
m
.
sqrt
(
c1
*
c1
+
c2
*
c2
);
that
.
originX
=
m
.
abs
(
e
.
touches
[
0
].
pageX
+
e
.
touches
[
1
].
pageX
-
that
.
wrapperOffsetLeft
*
2
)
/
2
-
that
.
x
;
mouseWheelSpeed
:
20
,
that
.
originY
=
m
.
abs
(
e
.
touches
[
0
].
pageY
+
e
.
touches
[
1
].
pageY
-
that
.
wrapperOffsetTop
*
2
)
/
2
-
that
.
y
;
if
(
that
.
options
.
onZoomStart
)
that
.
options
.
onZoomStart
.
call
(
that
,
e
);
snapThreshold
:
0.334
,
}
if
(
that
.
options
.
momentum
)
{
// INSERT POINT: OPTIONS
disablePointer
:
!
utils
.
hasPointer
,
cancelFrame
(
that
.
aniTime
);
disableTouch
:
utils
.
hasPointer
||
!
utils
.
hasTouch
,
that
.
steps
=
[];
disableMouse
:
utils
.
hasPointer
||
utils
.
hasTouch
,
that
.
_pos
(
this
.
x
,
this
.
y
);
// это чтобы обновился экран
startX
:
0
,
if
(
that
.
options
.
onScrollEnd
)
startY
:
0
,
that
.
options
.
onScrollEnd
.
call
(
that
);
scrollY
:
true
,
}
directionLockThreshold
:
5
,
momentum
:
true
,
that
.
absStartX
=
that
.
x
;
// Needed by snap threshold
bounce
:
true
,
that
.
absStartY
=
that
.
y
;
bounceTime
:
600
,
bounceEasing
:
''
,
that
.
startX
=
that
.
x
;
preventDefault
:
true
,
that
.
startY
=
that
.
y
;
preventDefaultException
:
{
tagName
:
/^
(
INPUT|TEXTAREA|BUTTON|SELECT
)
$/
},
that
.
pointX
=
point
.
pageX
;
that
.
pointY
=
point
.
pageY
;
that
.
startTime
=
e
.
timeStamp
||
Date
.
now
();
HWCompositing
:
true
,
useTransition
:
true
,
useTransform
:
true
,
bindToWrapper
:
typeof
window
.
onmousedown
===
"
undefined
"
};
if
(
that
.
options
.
onScrollStart
)
that
.
options
.
onScrollStart
.
call
(
that
,
e
);
for
(
var
i
in
options
)
{
},
this
.
options
[
i
]
=
options
[
i
];
}
_move
:
function
(
e
)
{
var
that
=
this
,
point
=
hasTouch
?
e
.
touches
[
0
]
:
e
,
deltaX
=
point
.
pageX
-
that
.
pointX
,
deltaY
=
point
.
pageY
-
that
.
pointY
,
newX
=
that
.
x
+
deltaX
,
newY
=
that
.
y
+
deltaY
,
c1
,
c2
,
scale
,
timestamp
=
e
.
timeStamp
||
Date
.
now
();
if
(
that
.
options
.
onBeforeScrollMove
)
that
.
options
.
onBeforeScrollMove
.
call
(
that
,
e
);
// Normalize options
this
.
translateZ
=
this
.
options
.
HWCompositing
&&
utils
.
hasPerspective
?
'
translateZ(0)
'
:
''
;
// Zoom
this
.
options
.
useTransition
=
utils
.
hasTransition
&&
this
.
options
.
useTransition
;
if
(
that
.
options
.
zoom
&&
hasTouch
&&
e
.
touches
.
length
>
1
&&
that
.
scroller
)
this
.
options
.
useTransform
=
utils
.
hasTransform
&&
this
.
options
.
useTransform
;
{
c1
=
m
.
abs
(
e
.
touches
[
0
].
pageX
-
e
.
touches
[
1
].
pageX
);
c2
=
m
.
abs
(
e
.
touches
[
0
].
pageY
-
e
.
touches
[
1
].
pageY
);
that
.
touchesDist
=
m
.
sqrt
(
c1
*
c1
+
c2
*
c2
);
that
.
zoomed
=
true
;
this
.
options
.
eventPassthrough
=
this
.
options
.
eventPassthrough
===
true
?
'
vertical
'
:
this
.
options
.
eventPassthrough
;
this
.
options
.
preventDefault
=
!
this
.
options
.
eventPassthrough
&&
this
.
options
.
preventDefault
;
scale
=
1
/
that
.
touchesDistStart
*
that
.
touchesDist
*
this
.
scale
;
// If you want eventPassthrough I have to lock one of the axes
this
.
options
.
scrollY
=
this
.
options
.
eventPassthrough
==
'
vertical
'
?
false
:
this
.
options
.
scrollY
;
this
.
options
.
scrollX
=
this
.
options
.
eventPassthrough
==
'
horizontal
'
?
false
:
this
.
options
.
scrollX
;
if
(
scale
<
that
.
options
.
zoomMin
)
scale
=
0.5
*
that
.
options
.
zoomMin
*
Math
.
pow
(
2.0
,
scale
/
that
.
options
.
zoomMin
);
// With eventPassthrough we also need lockDirection mechanism
else
if
(
scale
>
that
.
options
.
zoomMax
)
scale
=
2.0
*
that
.
options
.
zoomMax
*
Math
.
pow
(
0.5
,
that
.
options
.
zoomMax
/
scale
);
this
.
options
.
freeScroll
=
this
.
options
.
freeScroll
&&
!
this
.
options
.
eventPassthrough
;
this
.
options
.
directionLockThreshold
=
this
.
options
.
eventPassthrough
?
0
:
this
.
options
.
directionLockThreshold
;
that
.
lastScale
=
scale
/
this
.
scale
;
this
.
options
.
bounceEasing
=
typeof
this
.
options
.
bounceEasing
==
'
string
'
?
utils
.
ease
[
this
.
options
.
bounceEasing
]
||
utils
.
ease
.
circular
:
this
.
options
.
bounceEasing
;
newX
=
this
.
originX
-
this
.
originX
*
that
.
lastScale
+
this
.
x
;
this
.
options
.
resizePolling
=
this
.
options
.
resizePolling
===
undefined
?
60
:
this
.
options
.
resizePolling
;
newY
=
this
.
originY
-
this
.
originY
*
that
.
lastScale
+
this
.
y
;
this
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
newX
+
'
px,
'
+
newY
+
'
px) scale(
'
+
scale
+
'
)
'
+
translateZ
;
if
(
this
.
options
.
tap
===
true
)
{
this
.
options
.
tap
=
'
tap
'
;
}
if
(
that
.
options
.
onZoom
)
that
.
options
.
onZoom
.
call
(
that
,
e
);
// https://github.com/cubiq/iscroll/issues/1029
return
;
if
(
!
this
.
options
.
useTransition
&&
!
this
.
options
.
useTransform
)
{
if
(
!
(
/relative|absolute/i
).
test
(
this
.
scrollerStyle
.
position
))
{
this
.
scrollerStyle
.
position
=
"
relative
"
;
}
}
}
that
.
pointX
=
point
.
pageX
;
if
(
this
.
options
.
shrinkScrollbars
==
'
scale
'
)
{
that
.
pointY
=
point
.
pageY
;
this
.
options
.
useTransition
=
false
;
}
// Slow down if outside of the boundaries
this
.
options
.
invertWheelDirection
=
this
.
options
.
invertWheelDirection
?
-
1
:
1
;
if
(
newX
>
0
||
newX
<
that
.
maxScrollX
)
{
newX
=
that
.
options
.
bounce
?
that
.
x
+
(
deltaX
/
2
)
:
newX
>=
0
||
that
.
maxScrollX
>=
0
?
0
:
that
.
maxScrollX
;
}
if
(
newY
>
that
.
minScrollY
||
newY
<
that
.
maxScrollY
)
{
newY
=
that
.
options
.
bounce
?
that
.
y
+
(
deltaY
/
2
)
:
newY
>=
that
.
minScrollY
||
that
.
maxScrollY
>=
0
?
that
.
minScrollY
:
that
.
maxScrollY
;
}
that
.
distX
+=
deltaX
;
// INSERT POINT: NORMALIZATION
that
.
distY
+=
deltaY
;
that
.
absDistX
=
m
.
abs
(
that
.
distX
);
that
.
absDistY
=
m
.
abs
(
that
.
distY
);
if
(
that
.
absDistX
<
6
&&
that
.
absDistY
<
6
)
{
// Some defaults
return
;
this
.
x
=
0
;
this
.
y
=
0
;
this
.
directionX
=
0
;
this
.
directionY
=
0
;
this
.
_events
=
{};
// INSERT POINT: DEFAULTS
this
.
_init
();
this
.
refresh
();
this
.
scrollTo
(
this
.
options
.
startX
,
this
.
options
.
startY
);
this
.
enable
();
}
IScroll
.
prototype
=
{
version
:
'
5.2.0
'
,
_init
:
function
()
{
this
.
_initEvents
();
if
(
this
.
options
.
scrollbars
||
this
.
options
.
indicators
)
{
this
.
_initIndicators
();
}
}
// Lock direction
if
(
this
.
options
.
mouseWheel
)
{
if
(
that
.
options
.
lockDirection
)
{
this
.
_initWheel
();
if
(
that
.
absDistX
>
that
.
absDistY
+
5
)
{
newY
=
that
.
y
;
deltaY
=
0
;
}
else
if
(
that
.
absDistY
>
that
.
absDistX
+
5
)
{
newX
=
that
.
x
;
deltaX
=
0
;
}
}
}
that
.
moved
=
true
;
if
(
this
.
options
.
snap
)
{
that
.
_pos
(
newX
,
newY
);
this
.
_initSnap
();
that
.
dirX
=
deltaX
>
0
?
-
1
:
deltaX
<
0
?
1
:
0
;
}
that
.
dirY
=
deltaY
>
0
?
-
1
:
deltaY
<
0
?
1
:
0
;
if
(
timestamp
-
that
.
startTime
>
300
)
{
if
(
this
.
options
.
keyBindings
)
{
that
.
startTime
=
timestamp
;
this
.
_initKeys
();
that
.
startX
=
that
.
x
;
that
.
startY
=
that
.
y
;
}
}
if
(
that
.
options
.
onScrollMove
)
that
.
options
.
onScrollMove
.
call
(
that
,
e
);
// INSERT POINT: _init
},
},
_end
:
function
(
e
)
{
if
(
hasTouch
&&
e
.
touches
.
length
!==
0
)
return
;
var
that
=
this
,
destroy
:
function
()
{
point
=
hasTouch
?
e
.
changedTouches
[
0
]
:
e
,
this
.
_initEvents
(
true
);
target
,
ev
,
clearTimeout
(
this
.
resizeTimeout
);
momentumX
=
{
dist
:
0
,
time
:
0
},
this
.
resizeTimeout
=
null
;
momentumY
=
{
dist
:
0
,
time
:
0
},
this
.
_execEvent
(
'
destroy
'
);
duration
=
(
e
.
timeStamp
||
Date
.
now
())
-
that
.
startTime
,
},
newPosX
=
that
.
x
,
newPosY
=
that
.
y
,
distX
,
distY
,
newDuration
,
snap
,
scale
;
if
(
that
.
options
.
onBeforeScrollEnd
)
that
.
options
.
onBeforeScrollEnd
.
call
(
that
,
e
);
if
(
that
.
zoomed
)
{
scale
=
that
.
scale
*
that
.
lastScale
;
scale
=
Math
.
max
(
that
.
options
.
zoomMin
,
scale
);
scale
=
Math
.
min
(
that
.
options
.
zoomMax
,
scale
);
that
.
lastScale
=
scale
/
that
.
scale
;
that
.
scale
=
scale
;
that
.
x
=
that
.
originX
-
that
.
originX
*
that
.
lastScale
+
that
.
x
;
that
.
y
=
that
.
originY
-
that
.
originY
*
that
.
lastScale
+
that
.
y
;
that
.
scroller
.
style
[
transitionDuration
]
=
'
200ms
'
;
that
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
that
.
x
+
'
px,
'
+
that
.
y
+
'
px) scale(
'
+
that
.
scale
+
'
)
'
+
translateZ
;
that
.
zoomed
=
false
;
that
.
refresh
();
if
(
that
.
options
.
onZoomEnd
)
that
.
options
.
onZoomEnd
.
call
(
that
,
e
);
_transitionEnd
:
function
(
e
)
{
if
(
e
.
target
!=
this
.
scroller
||
!
this
.
isInTransition
)
{
return
;
return
;
}
}
if
(
!
that
.
moved
)
{
this
.
_transitionTime
();
if
(
hasTouch
)
{
if
(
!
this
.
resetPosition
(
this
.
options
.
bounceTime
)
)
{
if
(
that
.
doubleTapTimer
&&
that
.
options
.
zoom
)
{
this
.
isInTransition
=
false
;
// Double tapped
this
.
_execEvent
(
'
scrollEnd
'
);
clearTimeout
(
that
.
doubleTapTimer
);
}
that
.
doubleTapTimer
=
null
;
},
if
(
that
.
options
.
onZoomStart
)
that
.
options
.
onZoomStart
.
call
(
that
,
e
);
that
.
zoom
(
that
.
pointX
,
that
.
pointY
,
that
.
scale
==
1
?
that
.
options
.
doubleTapZoom
:
1
);
if
(
that
.
options
.
onZoomEnd
)
{
setTimeout
(
function
()
{
that
.
options
.
onZoomEnd
.
call
(
that
,
e
);
},
200
);
// 200 is default zoom duration
}
}
else
if
(
this
.
options
.
handleClick
)
{
that
.
doubleTapTimer
=
setTimeout
(
function
()
{
that
.
doubleTapTimer
=
null
;
// Find the last touched element
target
=
point
.
target
;
while
(
target
.
nodeType
!=
1
)
target
=
target
.
parentNode
;
if
(
target
.
tagName
!=
'
SELECT
'
&&
target
.
tagName
!=
'
INPUT
'
&&
target
.
tagName
!=
'
TEXTAREA
'
)
{
ev
=
doc
.
createEvent
(
'
MouseEvents
'
);
ev
.
initMouseEvent
(
'
click
'
,
true
,
true
,
e
.
view
,
1
,
point
.
screenX
,
point
.
screenY
,
point
.
clientX
,
point
.
clientY
,
e
.
ctrlKey
,
e
.
altKey
,
e
.
shiftKey
,
e
.
metaKey
,
0
,
null
);
ev
.
_fake
=
true
;
target
.
dispatchEvent
(
ev
);
}
},
that
.
options
.
zoom
?
250
:
0
);
}
}
that
.
_resetPos
(
400
);
_start
:
function
(
e
)
{
// React to left mouse button only
if
(
utils
.
eventType
[
e
.
type
]
!=
1
)
{
// for button property
// http://unixpapa.com/js/mouse.html
var
button
;
if
(
!
e
.
which
)
{
/* IE case */
button
=
(
e
.
button
<
2
)
?
0
:
((
e
.
button
==
4
)
?
1
:
2
);
}
else
{
/* All others */
button
=
e
.
button
;
}
if
(
button
!==
0
)
{
return
;
}
}
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
if
(
!
this
.
enabled
||
(
this
.
initiated
&&
utils
.
eventType
[
e
.
type
]
!==
this
.
initiated
)
)
{
return
;
return
;
}
}
if
(
duration
<
300
&&
that
.
options
.
momentum
)
{
if
(
this
.
options
.
preventDefault
&&
!
utils
.
isBadAndroid
&&
!
utils
.
preventDefaultException
(
e
.
target
,
this
.
options
.
preventDefaultException
)
)
{
momentumX
=
newPosX
?
that
.
_momentum
(
newPosX
-
that
.
startX
,
duration
,
-
that
.
x
,
that
.
scrollerW
-
that
.
wrapperW
+
that
.
x
,
that
.
options
.
bounce
?
that
.
wrapperW
:
0
)
:
momentumX
;
e
.
preventDefault
();
momentumY
=
newPosY
?
that
.
_momentum
(
newPosY
-
that
.
startY
,
duration
,
-
that
.
y
,
(
that
.
maxScrollY
<
0
?
that
.
scrollerH
-
that
.
wrapperH
+
that
.
y
-
that
.
minScrollY
:
0
),
that
.
options
.
bounce
?
that
.
wrapperH
:
0
)
:
momentumY
;
newPosX
=
that
.
x
+
momentumX
.
dist
;
newPosY
=
that
.
y
+
momentumY
.
dist
;
if
((
that
.
x
>
0
&&
newPosX
>
0
)
||
(
that
.
x
<
that
.
maxScrollX
&&
newPosX
<
that
.
maxScrollX
))
momentumX
=
{
dist
:
0
,
time
:
0
};
if
((
that
.
y
>
that
.
minScrollY
&&
newPosY
>
that
.
minScrollY
)
||
(
that
.
y
<
that
.
maxScrollY
&&
newPosY
<
that
.
maxScrollY
))
momentumY
=
{
dist
:
0
,
time
:
0
};
}
}
if
(
momentumX
.
dist
||
momentumY
.
dist
)
{
var
point
=
e
.
touches
?
e
.
touches
[
0
]
:
e
,
newDuration
=
m
.
max
(
m
.
max
(
momentumX
.
time
,
momentumY
.
time
),
10
);
pos
;
this
.
initiated
=
utils
.
eventType
[
e
.
type
];
this
.
moved
=
false
;
this
.
distX
=
0
;
this
.
distY
=
0
;
this
.
directionX
=
0
;
this
.
directionY
=
0
;
this
.
directionLocked
=
0
;
this
.
startTime
=
utils
.
getTime
();
if
(
this
.
options
.
useTransition
&&
this
.
isInTransition
)
{
this
.
_transitionTime
();
this
.
isInTransition
=
false
;
pos
=
this
.
getComputedPosition
();
this
.
_translate
(
Math
.
round
(
pos
.
x
),
Math
.
round
(
pos
.
y
));
this
.
_execEvent
(
'
scrollEnd
'
);
}
else
if
(
!
this
.
options
.
useTransition
&&
this
.
isAnimating
)
{
this
.
isAnimating
=
false
;
this
.
_execEvent
(
'
scrollEnd
'
);
}
// Do we need to snap?
this
.
startX
=
this
.
x
;
if
(
that
.
options
.
snap
)
{
this
.
startY
=
this
.
y
;
distX
=
newPosX
-
that
.
absStartX
;
this
.
absStartX
=
this
.
x
;
distY
=
newPosY
-
that
.
absStartY
;
this
.
absStartY
=
this
.
y
;
if
(
m
.
abs
(
distX
)
<
that
.
options
.
snapThreshold
&&
m
.
abs
(
distY
)
<
that
.
options
.
snapThreshold
)
{
that
.
scrollTo
(
that
.
absStartX
,
that
.
absStartY
,
200
);
}
this
.
pointX
=
point
.
pageX
;
else
{
this
.
pointY
=
point
.
pageY
;
snap
=
that
.
_snap
(
newPosX
,
newPosY
);
newPosX
=
snap
.
x
;
newPosY
=
snap
.
y
;
newDuration
=
m
.
max
(
snap
.
time
,
newDuration
);
}
}
that
.
scrollTo
(
m
.
round
(
newPosX
),
m
.
round
(
newPosY
),
newDuration
);
this
.
_execEvent
(
'
beforeScrollStart
'
);
},
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
_move
:
function
(
e
)
{
if
(
!
this
.
enabled
||
utils
.
eventType
[
e
.
type
]
!==
this
.
initiated
)
{
return
;
return
;
}
}
// Do we need to snap?
if
(
this
.
options
.
preventDefault
)
{
// increases performance on Android? TODO: check!
if
(
that
.
options
.
snap
)
{
e
.
preventDefault
();
distX
=
newPosX
-
that
.
absStartX
;
}
distY
=
newPosY
-
that
.
absStartY
;
if
(
m
.
abs
(
distX
)
<
that
.
options
.
snapThreshold
&&
m
.
abs
(
distY
)
<
that
.
options
.
snapThreshold
)
that
.
scrollTo
(
that
.
absStartX
,
that
.
absStartY
,
200
);
var
point
=
e
.
touches
?
e
.
touches
[
0
]
:
e
,
else
{
deltaX
=
point
.
pageX
-
this
.
pointX
,
snap
=
that
.
_snap
(
that
.
x
,
that
.
y
);
deltaY
=
point
.
pageY
-
this
.
pointY
,
if
(
snap
.
x
!=
that
.
x
||
snap
.
y
!=
that
.
y
)
that
.
scrollTo
(
snap
.
x
,
snap
.
y
,
snap
.
time
);
timestamp
=
utils
.
getTime
(),
}
newX
,
newY
,
absDistX
,
absDistY
;
this
.
pointX
=
point
.
pageX
;
this
.
pointY
=
point
.
pageY
;
this
.
distX
+=
deltaX
;
this
.
distY
+=
deltaY
;
absDistX
=
Math
.
abs
(
this
.
distX
);
absDistY
=
Math
.
abs
(
this
.
distY
);
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
// We need to move at least 10 pixels for the scrolling to initiate
if
(
timestamp
-
this
.
endTime
>
300
&&
(
absDistX
<
10
&&
absDistY
<
10
)
)
{
return
;
return
;
}
}
that
.
_resetPos
(
200
);
// If you are scrolling in one direction lock the other
if
(
that
.
options
.
onTouchEnd
)
that
.
options
.
onTouchEnd
.
call
(
that
,
e
);
if
(
!
this
.
directionLocked
&&
!
this
.
options
.
freeScroll
)
{
},
if
(
absDistX
>
absDistY
+
this
.
options
.
directionLockThreshold
)
{
this
.
directionLocked
=
'
h
'
;
// lock horizontally
_resetPos
:
function
(
time
)
{
}
else
if
(
absDistY
>=
absDistX
+
this
.
options
.
directionLockThreshold
)
{
var
that
=
this
,
this
.
directionLocked
=
'
v
'
;
// lock vertically
resetX
=
that
.
x
>=
0
?
0
:
that
.
x
<
that
.
maxScrollX
?
that
.
maxScrollX
:
that
.
x
,
}
else
{
resetY
=
that
.
y
>=
that
.
minScrollY
||
that
.
maxScrollY
>
0
?
that
.
minScrollY
:
that
.
y
<
that
.
maxScrollY
?
that
.
maxScrollY
:
that
.
y
;
this
.
directionLocked
=
'
n
'
;
// no lock
if
(
resetX
==
that
.
x
&&
resetY
==
that
.
y
)
{
if
(
that
.
moved
)
{
that
.
moved
=
false
;
if
(
that
.
options
.
onScrollEnd
)
that
.
options
.
onScrollEnd
.
call
(
that
);
// Execute custom code on scroll end
}
}
}
if
(
that
.
hScrollbar
&&
that
.
options
.
hideScrollbar
)
{
if
(
this
.
directionLocked
==
'
h
'
)
{
if
(
vendor
==
'
webkit
'
)
that
.
hScrollbarWrapper
.
style
[
transitionDelay
]
=
'
300ms
'
;
if
(
this
.
options
.
eventPassthrough
==
'
vertical
'
)
{
that
.
hScrollbarWrapper
.
style
.
opacity
=
'
0
'
;
e
.
preventDefault
();
}
else
if
(
this
.
options
.
eventPassthrough
==
'
horizontal
'
)
{
this
.
initiated
=
false
;
return
;
}
}
if
(
that
.
vScrollbar
&&
that
.
options
.
hideScrollbar
)
{
if
(
vendor
==
'
webkit
'
)
that
.
vScrollbarWrapper
.
style
[
transitionDelay
]
=
'
300ms
'
;
deltaY
=
0
;
that
.
vScrollbarWrapper
.
style
.
opacity
=
'
0
'
;
}
else
if
(
this
.
directionLocked
==
'
v
'
)
{
if
(
this
.
options
.
eventPassthrough
==
'
horizontal
'
)
{
e
.
preventDefault
();
}
else
if
(
this
.
options
.
eventPassthrough
==
'
vertical
'
)
{
this
.
initiated
=
false
;
return
;
}
}
return
;
deltaX
=
0
;
}
}
that
.
scrollTo
(
resetX
,
resetY
,
time
||
0
)
;
deltaX
=
this
.
hasHorizontalScroll
?
deltaX
:
0
;
},
deltaY
=
this
.
hasVerticalScroll
?
deltaY
:
0
;
_wheel
:
function
(
e
)
{
newX
=
this
.
x
+
deltaX
;
var
that
=
this
,
newY
=
this
.
y
+
deltaY
;
wheelDeltaX
,
wheelDeltaY
,
deltaX
,
deltaY
,
// Slow down if outside of the boundaries
deltaScale
;
if
(
newX
>
0
||
newX
<
this
.
maxScrollX
)
{
newX
=
this
.
options
.
bounce
?
this
.
x
+
deltaX
/
3
:
newX
>
0
?
0
:
this
.
maxScrollX
;
if
(
'
wheelDeltaX
'
in
e
)
{
wheelDeltaX
=
e
[
'
wheelDeltaX
'
]
/
12
;
wheelDeltaY
=
e
[
'
wheelDeltaY
'
]
/
12
;
}
else
if
(
'
wheelDelta
'
in
e
)
{
wheelDeltaX
=
wheelDeltaY
=
e
[
'
wheelDelta
'
]
/
12
;
}
else
if
(
'
detail
'
in
e
)
{
wheelDeltaX
=
wheelDeltaY
=
-
e
[
'
detail
'
]
*
3
;
}
else
{
return
;
}
}
if
(
newY
>
0
||
newY
<
this
.
maxScrollY
)
{
if
(
that
.
options
.
wheelAction
==
'
zoom
'
)
{
newY
=
this
.
options
.
bounce
?
this
.
y
+
deltaY
/
3
:
newY
>
0
?
0
:
this
.
maxScrollY
;
deltaScale
=
that
.
scale
*
Math
.
pow
(
2
,
1
/
3
*
(
wheelDeltaY
?
wheelDeltaY
/
Math
.
abs
(
wheelDeltaY
)
:
0
));
if
(
deltaScale
<
that
.
options
.
zoomMin
)
deltaScale
=
that
.
options
.
zoomMin
;
if
(
deltaScale
>
that
.
options
.
zoomMax
)
deltaScale
=
that
.
options
.
zoomMax
;
if
(
deltaScale
!=
that
.
scale
)
{
if
(
!
that
.
wheelZoomCount
&&
that
.
options
.
onZoomStart
)
that
.
options
.
onZoomStart
.
call
(
that
,
e
);
that
.
wheelZoomCount
++
;
that
.
zoom
(
e
.
pageX
,
e
.
pageY
,
deltaScale
,
400
);
setTimeout
(
function
()
{
that
.
wheelZoomCount
--
;
if
(
!
that
.
wheelZoomCount
&&
that
.
options
.
onZoomEnd
)
that
.
options
.
onZoomEnd
.
call
(
that
,
e
);
},
400
);
}
return
;
}
}
deltaX
=
that
.
x
+
wheelDeltaX
;
deltaY
=
that
.
y
+
wheelDeltaY
;
if
(
deltaX
>
0
)
deltaX
=
0
;
this
.
directionX
=
deltaX
>
0
?
-
1
:
deltaX
<
0
?
1
:
0
;
else
if
(
deltaX
<
that
.
maxScrollX
)
deltaX
=
that
.
maxScrollX
;
this
.
directionY
=
deltaY
>
0
?
-
1
:
deltaY
<
0
?
1
:
0
;
if
(
deltaY
>
that
.
minScrollY
)
deltaY
=
that
.
minScrollY
;
if
(
!
this
.
moved
)
{
else
if
(
deltaY
<
that
.
maxScrollY
)
deltaY
=
that
.
maxScrollY
;
this
.
_execEvent
(
'
scrollStart
'
);
if
(
that
.
maxScrollY
<
0
)
{
that
.
scrollTo
(
deltaX
,
deltaY
,
0
);
}
}
},
_transitionEnd
:
function
(
e
)
{
var
that
=
this
;
if
(
e
.
target
!=
that
.
scroller
)
return
;
this
.
moved
=
true
;
this
.
_translate
(
newX
,
newY
);
that
.
_unbind
(
TRNEND_EV
);
/* REPLACE START: _move */
if
(
timestamp
-
this
.
startTime
>
300
)
{
this
.
startTime
=
timestamp
;
this
.
startX
=
this
.
x
;
this
.
startY
=
this
.
y
;
}
that
.
_startAni
();
// !!!
},
this
.
_execEvent
(
'
scroll
'
);
/* REPLACE END: _move */
/**
},
*
* Utilities
*
*/
_startAni
:
function
()
{
var
that
=
this
,
startX
=
that
.
x
,
startY
=
that
.
y
,
startTime
=
Date
.
now
(),
step
,
easeOut
,
animate
;
if
(
that
.
animating
)
return
;
_end
:
function
(
e
)
{
if
(
!
this
.
enabled
||
utils
.
eventType
[
e
.
type
]
!==
this
.
initiated
)
{
if
(
!
that
.
steps
.
length
)
{
that
.
_resetPos
(
400
);
return
;
return
;
}
}
step
=
that
.
steps
.
shift
();
if
(
step
.
x
==
startX
&&
step
.
y
==
startY
)
step
.
time
=
0
;
that
.
animating
=
true
;
if
(
this
.
options
.
preventDefault
&&
!
utils
.
preventDefaultException
(
e
.
target
,
this
.
options
.
preventDefaultException
)
)
{
that
.
moved
=
true
;
e
.
preventDefault
();
}
if
(
that
.
options
.
useTransition
)
{
that
.
_transitionTime
(
step
.
time
);
var
point
=
e
.
changedTouches
?
e
.
changedTouches
[
0
]
:
e
,
that
.
_pos
(
step
.
x
,
step
.
y
);
momentumX
,
that
.
animating
=
false
;
momentumY
,
if
(
step
.
time
)
that
.
_bind
(
TRNEND_EV
);
duration
=
utils
.
getTime
()
-
this
.
startTime
,
else
that
.
_resetPos
(
0
);
newX
=
Math
.
round
(
this
.
x
),
newY
=
Math
.
round
(
this
.
y
),
distanceX
=
Math
.
abs
(
newX
-
this
.
startX
),
distanceY
=
Math
.
abs
(
newY
-
this
.
startY
),
time
=
0
,
easing
=
''
;
this
.
isInTransition
=
0
;
this
.
initiated
=
0
;
this
.
endTime
=
utils
.
getTime
();
// reset if we are outside of the boundaries
if
(
this
.
resetPosition
(
this
.
options
.
bounceTime
)
)
{
return
;
return
;
}
}
animate
=
function
()
{
this
.
scrollTo
(
newX
,
newY
);
// ensures that the last position is rounded
var
now
=
Date
.
now
(),
newX
,
newY
;
if
(
now
>=
startTime
+
step
.
time
)
{
// we scrolled less than 10 pixels
that
.
_pos
(
step
.
x
,
step
.
y
);
if
(
!
this
.
moved
)
{
that
.
animating
=
false
;
if
(
this
.
options
.
tap
)
{
if
(
that
.
options
.
onAnimationEnd
)
utils
.
tap
(
e
,
this
.
options
.
tap
);
that
.
options
.
onAnimationEnd
(
that
);
// Execute custom code on animation end
that
.
_startAni
();
return
;
}
}
now
=
(
now
-
startTime
)
/
step
.
time
-
1
;
if
(
this
.
options
.
click
)
{
easeOut
=
m
.
sqrt
(
1
-
now
*
now
);
utils
.
click
(
e
);
newX
=
(
step
.
x
-
startX
)
*
easeOut
+
startX
;
}
newY
=
(
step
.
y
-
startY
)
*
easeOut
+
startY
;
that
.
_pos
(
newX
,
newY
,
true
);
if
(
that
.
animating
)
that
.
aniTime
=
nextFrame
(
animate
);
};
animate
();
this
.
_execEvent
(
'
scrollCancel
'
);
},
return
;
}
_transitionTime
:
function
(
time
)
{
if
(
this
.
_events
.
flick
&&
duration
<
200
&&
distanceX
<
100
&&
distanceY
<
100
)
{
time
+=
'
ms
'
;
this
.
_execEvent
(
'
flick
'
);
this
.
scroller
.
style
[
transitionDuration
]
=
time
;
return
;
if
(
this
.
hScrollbar
)
this
.
hScrollbarIndicator
.
style
[
transitionDuration
]
=
time
;
}
if
(
this
.
vScrollbar
)
this
.
vScrollbarIndicator
.
style
[
transitionDuration
]
=
time
;
},
_momentum
:
function
(
dist
,
time
,
maxDistUpper
,
maxDistLower
,
size
)
{
// start momentum animation if needed
var
deceleration
=
0.0006
,
if
(
this
.
options
.
momentum
&&
duration
<
300
)
{
speed
=
m
.
abs
(
dist
)
/
time
,
momentumX
=
this
.
hasHorizontalScroll
?
utils
.
momentum
(
this
.
x
,
this
.
startX
,
duration
,
this
.
maxScrollX
,
this
.
options
.
bounce
?
this
.
wrapperWidth
:
0
,
this
.
options
.
deceleration
)
:
{
destination
:
newX
,
duration
:
0
};
newDist
=
(
speed
*
speed
)
/
(
2
*
deceleration
),
momentumY
=
this
.
hasVerticalScroll
?
utils
.
momentum
(
this
.
y
,
this
.
startY
,
duration
,
this
.
maxScrollY
,
this
.
options
.
bounce
?
this
.
wrapperHeight
:
0
,
this
.
options
.
deceleration
)
:
{
destination
:
newY
,
duration
:
0
};
newTime
=
0
,
outsideDist
=
0
;
newX
=
momentumX
.
destination
;
newY
=
momentumY
.
destination
;
// Proportinally reduce speed if we are outside of the boundaries
time
=
Math
.
max
(
momentumX
.
duration
,
momentumY
.
duration
);
if
(
dist
>
0
&&
newDist
>
maxDistUpper
)
{
this
.
isInTransition
=
1
;
outsideDist
=
size
/
(
6
/
(
newDist
/
speed
*
deceleration
));
}
maxDistUpper
=
maxDistUpper
+
outsideDist
;
speed
=
speed
*
maxDistUpper
/
newDist
;
newDist
=
maxDistUpper
;
}
else
if
(
dist
<
0
&&
newDist
>
maxDistLower
)
{
outsideDist
=
size
/
(
6
/
(
newDist
/
speed
*
deceleration
));
maxDistLower
=
maxDistLower
+
outsideDist
;
speed
=
speed
*
maxDistLower
/
newDist
;
newDist
=
maxDistLower
;
}
newDist
=
newDist
*
(
dist
<
0
?
-
1
:
1
);
newTime
=
speed
/
deceleration
;
return
{
dist
:
newDist
,
time
:
m
.
round
(
newTime
)
};
},
_offset
:
function
(
el
)
{
var
left
=
-
el
.
offsetLeft
,
if
(
this
.
options
.
snap
)
{
top
=
-
el
.
offsetTop
;
var
snap
=
this
.
_nearestSnap
(
newX
,
newY
);
this
.
currentPage
=
snap
;
while
(
el
=
el
.
offsetParent
)
{
time
=
this
.
options
.
snapSpeed
||
Math
.
max
(
left
-=
el
.
offsetLeft
;
Math
.
max
(
top
-=
el
.
offsetTop
;
Math
.
min
(
Math
.
abs
(
newX
-
snap
.
x
),
1000
),
Math
.
min
(
Math
.
abs
(
newY
-
snap
.
y
),
1000
)
),
300
);
newX
=
snap
.
x
;
newY
=
snap
.
y
;
this
.
directionX
=
0
;
this
.
directionY
=
0
;
easing
=
this
.
options
.
bounceEasing
;
}
}
if
(
el
!=
this
.
wrapper
)
{
// INSERT POINT: _end
left
*=
this
.
scale
;
top
*=
this
.
scale
;
if
(
newX
!=
this
.
x
||
newY
!=
this
.
y
)
{
// change easing function when scroller goes out of the boundaries
if
(
newX
>
0
||
newX
<
this
.
maxScrollX
||
newY
>
0
||
newY
<
this
.
maxScrollY
)
{
easing
=
utils
.
ease
.
quadratic
;
}
this
.
scrollTo
(
newX
,
newY
,
time
,
easing
);
return
;
}
}
return
{
left
:
left
,
top
:
top
}
;
this
.
_execEvent
(
'
scrollEnd
'
)
;
},
},
_snap
:
function
(
x
,
y
)
{
_resize
:
function
()
{
var
that
=
this
,
var
that
=
this
;
i
,
l
,
page
,
time
,
clearTimeout
(
this
.
resizeTimeout
);
sizeX
,
sizeY
;
this
.
resizeTimeout
=
setTimeout
(
function
()
{
// Check page X
that
.
refresh
();
page
=
that
.
pagesX
.
length
-
1
;
},
this
.
options
.
resizePolling
);
for
(
i
=
0
,
l
=
that
.
pagesX
.
length
;
i
<
l
;
i
++
)
{
},
if
(
x
>=
that
.
pagesX
[
i
])
{
page
=
i
;
resetPosition
:
function
(
time
)
{
break
;
var
x
=
this
.
x
,
}
y
=
this
.
y
;
time
=
time
||
0
;
if
(
!
this
.
hasHorizontalScroll
||
this
.
x
>
0
)
{
x
=
0
;
}
else
if
(
this
.
x
<
this
.
maxScrollX
)
{
x
=
this
.
maxScrollX
;
}
}
if
(
page
==
that
.
currPageX
&&
page
>
0
&&
that
.
dirX
<
0
)
page
--
;
x
=
that
.
pagesX
[
page
];
if
(
!
this
.
hasVerticalScroll
||
this
.
y
>
0
)
{
sizeX
=
m
.
abs
(
x
-
that
.
pagesX
[
that
.
currPageX
]);
y
=
0
;
sizeX
=
sizeX
?
m
.
abs
(
that
.
x
-
x
)
/
sizeX
*
500
:
0
;
}
else
if
(
this
.
y
<
this
.
maxScrollY
)
{
that
.
currPageX
=
page
;
y
=
this
.
maxScrollY
;
}
// Check page Y
page
=
that
.
pagesY
.
length
-
1
;
if
(
x
==
this
.
x
&&
y
==
this
.
y
)
{
for
(
i
=
0
;
i
<
page
;
i
++
)
{
return
false
;
if
(
y
>=
that
.
pagesY
[
i
])
{
page
=
i
;
break
;
}
}
}
if
(
page
==
that
.
currPageY
&&
page
>
0
&&
that
.
dirY
<
0
)
page
--
;
y
=
that
.
pagesY
[
page
];
sizeY
=
m
.
abs
(
y
-
that
.
pagesY
[
that
.
currPageY
]);
sizeY
=
sizeY
?
m
.
abs
(
that
.
y
-
y
)
/
sizeY
*
500
:
0
;
that
.
currPageY
=
page
;
// Snap with constant speed (proportional duration)
this
.
scrollTo
(
x
,
y
,
time
,
this
.
options
.
bounceEasing
);
time
=
m
.
round
(
m
.
max
(
sizeX
,
sizeY
))
||
200
;
return
{
x
:
x
,
y
:
y
,
time
:
time
}
;
return
true
;
},
},
_bind
:
function
(
type
,
el
,
bubble
)
{
disable
:
function
(
)
{
(
el
||
this
.
scroller
).
addEventListener
(
type
,
this
,
!!
bubble
)
;
this
.
enabled
=
false
;
},
},
_unbind
:
function
(
type
,
el
,
bubble
)
{
enable
:
function
(
)
{
(
el
||
this
.
scroller
).
removeEventListener
(
type
,
this
,
!!
bubble
)
;
this
.
enabled
=
true
;
},
},
refresh
:
function
()
{
var
rf
=
this
.
wrapper
.
offsetHeight
;
// Force reflow
/**
this
.
wrapperWidth
=
this
.
wrapper
.
clientWidth
;
*
this
.
wrapperHeight
=
this
.
wrapper
.
clientHeight
;
* Public methods
*
*/
destroy
:
function
()
{
var
that
=
this
;
that
.
scroller
.
style
[
transform
]
=
''
;
/* REPLACE START: refresh */
// Remove the scrollbars
this
.
scrollerWidth
=
this
.
scroller
.
offsetWidth
;
that
.
hScrollbar
=
false
;
this
.
scrollerHeight
=
this
.
scroller
.
offsetHeight
;
that
.
vScrollbar
=
false
;
that
.
_scrollbar
(
'
h
'
);
that
.
_scrollbar
(
'
v
'
);
// Remove the event listeners
this
.
maxScrollX
=
this
.
wrapperWidth
-
this
.
scrollerWidth
;
if
(
that
.
options
.
useTransition
)
that
.
_unbind
(
TRNEND_EV
);
this
.
maxScrollY
=
this
.
wrapperHeight
-
this
.
scrollerHeight
;
if
(
that
.
options
.
onDestroy
)
that
.
options
.
onDestroy
.
call
(
that
);
},
_changeMaxes
:
function
()
/* REPLACE END: refresh */
{
var
that
=
this
;
var
_elem
=
that
.
api
.
ReaderModeDiv
;
that
.
scrollerW
=
m
.
round
(
_elem
.
offsetWidth
);
that
.
scrollerH
=
m
.
round
(
_elem
.
offsetHeight
+
that
.
minScrollY
);
that
.
maxScrollX
=
that
.
wrapperW
-
that
.
scrollerW
;
that
.
maxScrollY
=
that
.
wrapperH
-
that
.
scrollerH
+
that
.
minScrollY
;
that
.
_scrollbar
(
'
h
'
);
this
.
hasHorizontalScroll
=
this
.
options
.
scrollX
&&
this
.
maxScrollX
<
0
;
that
.
_scrollbar
(
'
v
'
);
this
.
hasVerticalScroll
=
this
.
options
.
scrollY
&&
this
.
maxScrollY
<
0
;
},
refresh
:
function
(
bIsNoReaderAttack
)
{
if
(
!
this
.
hasHorizontalScroll
)
{
var
that
=
this
,
this
.
maxScrollX
=
0
;
offset
,
this
.
scrollerWidth
=
this
.
wrapperWidth
;
i
,
l
,
}
els
,
pos
=
0
,
page
=
0
;
if
(
that
.
scale
<
that
.
options
.
zoomMin
)
if
(
!
this
.
hasVerticalScroll
)
{
that
.
scale
=
that
.
options
.
zoomMin
;
this
.
maxScrollY
=
0
;
this
.
scrollerHeight
=
this
.
wrapperHeight
;
}
that
.
wrapperW
=
((
that
.
api
.
m_oEditor
.
HtmlElement
.
width
)
||
1
)
>>
0
;
this
.
endTime
=
0
;
that
.
wrapperH
=
((
that
.
api
.
m_oEditor
.
HtmlElement
.
height
)
||
1
)
>>
0
;
this
.
directionX
=
0
;
this
.
directionY
=
0
;
if
(
that
.
api
.
bIsRetinaSupport
)
this
.
wrapperOffset
=
utils
.
offset
(
this
.
wrapper
);
{
that
.
wrapperW
>>=
1
;
that
.
wrapperH
>>=
1
;
}
that
.
minScrollY
=
0
;
that
.
scrollerW
=
that
.
api
.
m_dDocumentWidth
;
that
.
scrollerH
=
that
.
api
.
m_dDocumentHeight
;
var
_oldMaxX
=
that
.
maxScrollX
;
var
_oldMaxY
=
that
.
maxScrollY
;
var
_oldX
=
that
.
x
;
var
_oldY
=
that
.
y
;
that
.
maxScrollX
=
-
that
.
api
.
m_dScrollX_max
;
that
.
maxScrollY
=
-
that
.
api
.
m_dScrollY_max
;
that
.
x
=
-
that
.
api
.
m_dScrollX
;
that
.
y
=
-
that
.
api
.
m_dScrollY
;
if
(
that
.
api
.
ReaderModeDiv
!=
null
&&
undefined
===
bIsNoReaderAttack
)
{
var
_elem
=
that
.
api
.
ReaderModeDiv
;
that
.
scrollerW
=
m
.
round
(
_elem
.
offsetWidth
);
that
.
scrollerH
=
m
.
round
(
_elem
.
offsetHeight
+
that
.
minScrollY
);
that
.
maxScrollX
=
that
.
wrapperW
-
that
.
scrollerW
;
that
.
maxScrollY
=
that
.
wrapperH
-
that
.
scrollerH
+
that
.
minScrollY
;
// теперь посмотрим
/*
that.y = 0;
if (0 < that.api.m_dScrollY_max)
{
that.y = (that.api.m_dScrollY * that.maxScrollY / that.api.m_dScrollY_max) >> 0;
}
*/
that
.
x
=
0
;
that
.
y
=
0
;
if
(
_oldMaxX
<
0
)
{
that
.
x
=
(
_oldX
*
that
.
maxScrollX
/
_oldMaxX
)
>>
0
;
if
(
that
.
x
>
0
)
that
.
x
=
0
;
if
(
that
.
x
<
that
.
maxScrollX
)
that
.
x
=
that
.
maxScrollX
;
}
if
(
_oldMaxY
<
0
)
{
that
.
y
=
(
_oldY
*
that
.
maxScrollY
/
_oldMaxY
)
>>
0
;
if
(
that
.
y
>
0
)
that
.
y
=
0
;
if
(
that
.
y
<
that
.
maxScrollY
)
that
.
y
=
that
.
maxScrollY
;
}
}
that
.
dirX
=
0
;
that
.
dirY
=
0
;
if
(
that
.
options
.
onRefresh
)
that
.
options
.
onRefresh
.
call
(
that
);
that
.
hScroll
=
that
.
options
.
hScroll
&&
that
.
maxScrollX
<
0
;
that
.
vScroll
=
that
.
options
.
vScroll
&&
(
!
that
.
options
.
bounceLock
&&
!
that
.
hScroll
||
that
.
scrollerH
>
that
.
wrapperH
);
that
.
hScrollbar
=
that
.
hScroll
&&
that
.
options
.
hScrollbar
;
that
.
vScrollbar
=
that
.
vScroll
&&
that
.
options
.
vScrollbar
&&
that
.
scrollerH
>
that
.
wrapperH
;
offset
=
that
.
_offset
(
that
.
wrapper
);
that
.
wrapperOffsetLeft
=
-
offset
.
left
;
that
.
wrapperOffsetTop
=
-
offset
.
top
;
// Prepare snap
if
(
typeof
that
.
options
.
snap
==
'
string
'
)
{
that
.
pagesX
=
[];
that
.
pagesY
=
[];
els
=
that
.
scroller
.
querySelectorAll
(
that
.
options
.
snap
);
for
(
i
=
0
,
l
=
els
.
length
;
i
<
l
;
i
++
)
{
pos
=
that
.
_offset
(
els
[
i
]);
pos
.
left
+=
that
.
wrapperOffsetLeft
;
pos
.
top
+=
that
.
wrapperOffsetTop
;
that
.
pagesX
[
i
]
=
pos
.
left
<
that
.
maxScrollX
?
that
.
maxScrollX
:
pos
.
left
*
that
.
scale
;
that
.
pagesY
[
i
]
=
pos
.
top
<
that
.
maxScrollY
?
that
.
maxScrollY
:
pos
.
top
*
that
.
scale
;
}
}
else
if
(
that
.
options
.
snap
)
{
that
.
pagesX
=
[];
while
(
pos
>=
that
.
maxScrollX
)
{
that
.
pagesX
[
page
]
=
pos
;
pos
=
pos
-
that
.
wrapperW
;
page
++
;
}
if
(
that
.
maxScrollX
%
that
.
wrapperW
)
that
.
pagesX
[
that
.
pagesX
.
length
]
=
that
.
maxScrollX
-
that
.
pagesX
[
that
.
pagesX
.
length
-
1
]
+
that
.
pagesX
[
that
.
pagesX
.
length
-
1
];
pos
=
0
;
page
=
0
;
that
.
pagesY
=
[];
while
(
pos
>=
that
.
maxScrollY
)
{
that
.
pagesY
[
page
]
=
pos
;
pos
=
pos
-
that
.
wrapperH
;
page
++
;
}
if
(
that
.
maxScrollY
%
that
.
wrapperH
)
that
.
pagesY
[
that
.
pagesY
.
length
]
=
that
.
maxScrollY
-
that
.
pagesY
[
that
.
pagesY
.
length
-
1
]
+
that
.
pagesY
[
that
.
pagesY
.
length
-
1
];
}
// Prepare the scrollbars
this
.
_execEvent
(
'
refresh
'
);
that
.
_scrollbar
(
'
h
'
);
that
.
_scrollbar
(
'
v
'
);
if
(
!
that
.
zoomed
&&
that
.
scroller
)
{
this
.
resetPosition
();
that
.
scroller
.
style
[
transitionDuration
]
=
'
0
'
;
that
.
_resetPos
(
400
);
}
},
scrollTo
:
function
(
x
,
y
,
time
,
relative
)
{
// INSERT POINT: _refresh
var
that
=
this
,
step
=
x
,
i
,
l
;
that
.
stop
();
},
if
(
!
step
.
length
)
step
=
[{
x
:
x
,
y
:
y
,
time
:
time
,
relative
:
relative
}];
on
:
function
(
type
,
fn
)
{
if
(
!
this
.
_events
[
type
]
)
{
for
(
i
=
0
,
l
=
step
.
length
;
i
<
l
;
i
++
)
{
this
.
_events
[
type
]
=
[];
if
(
step
[
i
].
relative
)
{
step
[
i
].
x
=
that
.
x
-
step
[
i
].
x
;
step
[
i
].
y
=
that
.
y
-
step
[
i
].
y
;
}
that
.
steps
.
push
({
x
:
step
[
i
].
x
,
y
:
step
[
i
].
y
,
time
:
step
[
i
].
time
||
0
});
}
}
th
at
.
_startAni
(
);
th
is
.
_events
[
type
].
push
(
fn
);
},
},
scrollToElement
:
function
(
el
,
time
)
{
off
:
function
(
type
,
fn
)
{
var
that
=
this
,
pos
;
if
(
!
this
.
_events
[
type
]
)
{
el
=
el
.
nodeType
?
el
:
that
.
scroller
.
querySelector
(
el
);
return
;
if
(
!
el
)
return
;
}
pos
=
that
.
_offset
(
el
);
pos
.
left
+=
that
.
wrapperOffsetLeft
;
pos
.
top
+=
that
.
wrapperOffsetTop
;
pos
.
left
=
pos
.
left
>
0
?
0
:
pos
.
left
<
that
.
maxScrollX
?
that
.
maxScrollX
:
pos
.
left
;
var
index
=
this
.
_events
[
type
].
indexOf
(
fn
);
pos
.
top
=
pos
.
top
>
that
.
minScrollY
?
that
.
minScrollY
:
pos
.
top
<
that
.
maxScrollY
?
that
.
maxScrollY
:
pos
.
top
;
time
=
time
===
undefined
?
m
.
max
(
m
.
abs
(
pos
.
left
)
*
2
,
m
.
abs
(
pos
.
top
)
*
2
)
:
time
;
that
.
scrollTo
(
pos
.
left
,
pos
.
top
,
time
);
if
(
index
>
-
1
)
{
this
.
_events
[
type
].
splice
(
index
,
1
);
}
},
},
scrollToPage
:
function
(
pageX
,
pageY
,
time
)
{
_execEvent
:
function
(
type
)
{
var
that
=
this
,
x
,
y
;
if
(
!
this
.
_events
[
type
]
)
{
return
;
time
=
time
===
undefined
?
400
:
time
;
}
if
(
that
.
options
.
onScrollStart
)
that
.
options
.
onScrollStart
.
call
(
that
);
if
(
that
.
options
.
snap
)
{
pageX
=
pageX
==
'
next
'
?
that
.
currPageX
+
1
:
pageX
==
'
prev
'
?
that
.
currPageX
-
1
:
pageX
;
pageY
=
pageY
==
'
next
'
?
that
.
currPageY
+
1
:
pageY
==
'
prev
'
?
that
.
currPageY
-
1
:
pageY
;
pageX
=
pageX
<
0
?
0
:
pageX
>
that
.
pagesX
.
length
-
1
?
that
.
pagesX
.
length
-
1
:
pageX
;
var
i
=
0
,
pageY
=
pageY
<
0
?
0
:
pageY
>
that
.
pagesY
.
length
-
1
?
that
.
pagesY
.
length
-
1
:
pageY
;
l
=
this
.
_events
[
type
].
length
;
that
.
currPageX
=
pageX
;
if
(
!
l
)
{
that
.
currPageY
=
pageY
;
return
;
x
=
that
.
pagesX
[
pageX
];
y
=
that
.
pagesY
[
pageY
];
}
else
{
x
=
-
that
.
wrapperW
*
pageX
;
y
=
-
that
.
wrapperH
*
pageY
;
if
(
x
<
that
.
maxScrollX
)
x
=
that
.
maxScrollX
;
if
(
y
<
that
.
maxScrollY
)
y
=
that
.
maxScrollY
;
}
}
that
.
scrollTo
(
x
,
y
,
time
);
for
(
;
i
<
l
;
i
++
)
{
this
.
_events
[
type
][
i
].
apply
(
this
,
[].
slice
.
call
(
arguments
,
1
));
}
},
},
disable
:
function
(
)
{
scrollBy
:
function
(
x
,
y
,
time
,
easing
)
{
this
.
stop
()
;
x
=
this
.
x
+
x
;
this
.
_resetPos
(
0
)
;
y
=
this
.
y
+
y
;
t
his
.
enabled
=
false
;
t
ime
=
time
||
0
;
// If disabled after touchstart we make sure that there are no left over events
this
.
scrollTo
(
x
,
y
,
time
,
easing
);
this
.
_unbind
(
CANCEL_EV
,
window
);
},
enable
:
function
()
{
this
.
enabled
=
true
;
},
},
stop
:
function
()
{
if
(
this
.
options
.
useTransition
)
this
.
_unbind
(
TRNEND_EV
);
else
cancelFrame
(
this
.
aniTime
);
this
.
steps
=
[];
this
.
moved
=
false
;
this
.
animating
=
false
;
},
zoom
:
function
(
x
,
y
,
scale
,
time
)
{
var
that
=
this
,
relScale
=
scale
/
that
.
scale
;
if
(
!
that
.
options
.
useTransform
)
return
;
scrollTo
:
function
(
x
,
y
,
time
,
easing
)
{
easing
=
easing
||
utils
.
ease
.
circular
;
that
.
zoomed
=
true
;
this
.
isInTransition
=
this
.
options
.
useTransition
&&
time
>
0
;
time
=
time
===
undefined
?
200
:
time
;
var
transitionType
=
this
.
options
.
useTransition
&&
easing
.
style
;
x
=
x
-
that
.
wrapperOffsetLeft
-
that
.
x
;
if
(
!
time
||
transitionType
)
{
y
=
y
-
that
.
wrapperOffsetTop
-
that
.
y
;
if
(
transitionType
)
{
that
.
x
=
x
-
x
*
relScale
+
that
.
x
;
this
.
_transitionTimingFunction
(
easing
.
style
);
that
.
y
=
y
-
y
*
relScale
+
that
.
y
;
this
.
_transitionTime
(
time
);
}
this
.
_translate
(
x
,
y
);
}
else
{
this
.
_animate
(
x
,
y
,
time
,
easing
.
fn
);
}
},
that
.
scale
=
scale
;
scrollToElement
:
function
(
el
,
time
,
offsetX
,
offsetY
,
easing
)
{
that
.
refresh
(
);
el
=
el
.
nodeType
?
el
:
this
.
scroller
.
querySelector
(
el
);
that
.
x
=
that
.
x
>
0
?
0
:
that
.
x
<
that
.
maxScrollX
?
that
.
maxScrollX
:
that
.
x
;
if
(
!
el
)
{
that
.
y
=
that
.
y
>
that
.
minScrollY
?
that
.
minScrollY
:
that
.
y
<
that
.
maxScrollY
?
that
.
maxScrollY
:
that
.
y
;
return
;
}
that
.
scroller
.
style
[
transitionDuration
]
=
time
+
'
ms
'
;
var
pos
=
utils
.
offset
(
el
);
that
.
scroller
.
style
[
transform
]
=
'
translate(
'
+
that
.
x
+
'
px,
'
+
that
.
y
+
'
px) scale(
'
+
scale
+
'
)
'
+
translateZ
;
that
.
zoomed
=
false
;
},
isReady
:
function
()
{
return
!
this
.
moved
&&
!
this
.
zoomed
&&
!
this
.
animating
;
}
};
function
prefixStyle
(
style
)
{
pos
.
left
-=
this
.
wrapperOffset
.
left
;
if
(
vendor
===
''
)
return
style
;
pos
.
top
-=
this
.
wrapperOffset
.
top
;
style
=
style
.
charAt
(
0
).
toUpperCase
()
+
style
.
substr
(
1
);
// if offsetX/Y are true we center the element to the screen
return
vendor
+
style
;
if
(
offsetX
===
true
)
{
offsetX
=
Math
.
round
(
el
.
offsetWidth
/
2
-
this
.
wrapper
.
offsetWidth
/
2
);
}
if
(
offsetY
===
true
)
{
offsetY
=
Math
.
round
(
el
.
offsetHeight
/
2
-
this
.
wrapper
.
offsetHeight
/
2
);
}
pos
.
left
-=
offsetX
||
0
;
pos
.
top
-=
offsetY
||
0
;
pos
.
left
=
pos
.
left
>
0
?
0
:
pos
.
left
<
this
.
maxScrollX
?
this
.
maxScrollX
:
pos
.
left
;
pos
.
top
=
pos
.
top
>
0
?
0
:
pos
.
top
<
this
.
maxScrollY
?
this
.
maxScrollY
:
pos
.
top
;
time
=
time
===
undefined
||
time
===
null
||
time
===
'
auto
'
?
Math
.
max
(
Math
.
abs
(
this
.
x
-
pos
.
left
),
Math
.
abs
(
this
.
y
-
pos
.
top
))
:
time
;
this
.
scrollTo
(
pos
.
left
,
pos
.
top
,
time
,
easing
);
},
_transitionTime
:
function
(
time
)
{
if
(
!
this
.
options
.
useTransition
)
{
return
;
}
time
=
time
||
0
;
var
durationProp
=
utils
.
style
.
transitionDuration
;
if
(
!
durationProp
)
{
return
;
}
this
.
scrollerStyle
[
durationProp
]
=
time
+
'
ms
'
;
if
(
!
time
&&
utils
.
isBadAndroid
)
{
this
.
scrollerStyle
[
durationProp
]
=
'
0.0001ms
'
;
// remove 0.0001ms
var
self
=
this
;
rAF
(
function
()
{
if
(
self
.
scrollerStyle
[
durationProp
]
===
'
0.0001ms
'
)
{
self
.
scrollerStyle
[
durationProp
]
=
'
0s
'
;
}
});
}
if
(
this
.
indicators
)
{
for
(
var
i
=
this
.
indicators
.
length
;
i
--
;
)
{
this
.
indicators
[
i
].
transitionTime
(
time
);
}
}
// INSERT POINT: _transitionTime
},
_transitionTimingFunction
:
function
(
easing
)
{
this
.
scrollerStyle
[
utils
.
style
.
transitionTimingFunction
]
=
easing
;
if
(
this
.
indicators
)
{
for
(
var
i
=
this
.
indicators
.
length
;
i
--
;
)
{
this
.
indicators
[
i
].
transitionTimingFunction
(
easing
);
}
}
// INSERT POINT: _transitionTimingFunction
},
_translate
:
function
(
x
,
y
)
{
if
(
this
.
options
.
useTransform
)
{
/* REPLACE START: _translate */
this
.
scrollerStyle
[
utils
.
style
.
transform
]
=
'
translate(
'
+
x
+
'
px,
'
+
y
+
'
px)
'
+
this
.
translateZ
;
/* REPLACE END: _translate */
}
else
{
x
=
Math
.
round
(
x
);
y
=
Math
.
round
(
y
);
this
.
scrollerStyle
.
left
=
x
+
'
px
'
;
this
.
scrollerStyle
.
top
=
y
+
'
px
'
;
}
this
.
x
=
x
;
this
.
y
=
y
;
if
(
this
.
indicators
)
{
for
(
var
i
=
this
.
indicators
.
length
;
i
--
;
)
{
this
.
indicators
[
i
].
updatePosition
();
}
}
// INSERT POINT: _translate
},
_initEvents
:
function
(
remove
)
{
var
eventType
=
remove
?
utils
.
removeEvent
:
utils
.
addEvent
,
target
=
this
.
options
.
bindToWrapper
?
this
.
wrapper
:
window
;
eventType
(
window
,
'
orientationchange
'
,
this
);
eventType
(
window
,
'
resize
'
,
this
);
if
(
this
.
options
.
click
)
{
eventType
(
this
.
wrapper
,
'
click
'
,
this
,
true
);
}
if
(
!
this
.
options
.
disableMouse
)
{
eventType
(
this
.
wrapper
,
'
mousedown
'
,
this
);
eventType
(
target
,
'
mousemove
'
,
this
);
eventType
(
target
,
'
mousecancel
'
,
this
);
eventType
(
target
,
'
mouseup
'
,
this
);
}
if
(
utils
.
hasPointer
&&
!
this
.
options
.
disablePointer
)
{
eventType
(
this
.
wrapper
,
utils
.
prefixPointerEvent
(
'
pointerdown
'
),
this
);
eventType
(
target
,
utils
.
prefixPointerEvent
(
'
pointermove
'
),
this
);
eventType
(
target
,
utils
.
prefixPointerEvent
(
'
pointercancel
'
),
this
);
eventType
(
target
,
utils
.
prefixPointerEvent
(
'
pointerup
'
),
this
);
}
if
(
utils
.
hasTouch
&&
!
this
.
options
.
disableTouch
)
{
eventType
(
this
.
wrapper
,
'
touchstart
'
,
this
);
eventType
(
target
,
'
touchmove
'
,
this
);
eventType
(
target
,
'
touchcancel
'
,
this
);
eventType
(
target
,
'
touchend
'
,
this
);
}
eventType
(
this
.
scroller
,
'
transitionend
'
,
this
);
eventType
(
this
.
scroller
,
'
webkitTransitionEnd
'
,
this
);
eventType
(
this
.
scroller
,
'
oTransitionEnd
'
,
this
);
eventType
(
this
.
scroller
,
'
MSTransitionEnd
'
,
this
);
},
getComputedPosition
:
function
()
{
var
matrix
=
window
.
getComputedStyle
(
this
.
scroller
,
null
),
x
,
y
;
if
(
this
.
options
.
useTransform
)
{
matrix
=
matrix
[
utils
.
style
.
transform
].
split
(
'
)
'
)[
0
].
split
(
'
,
'
);
x
=
+
(
matrix
[
12
]
||
matrix
[
4
]);
y
=
+
(
matrix
[
13
]
||
matrix
[
5
]);
}
else
{
x
=
+
matrix
.
left
.
replace
(
/
[^
-
\d
.
]
/g
,
''
);
y
=
+
matrix
.
top
.
replace
(
/
[^
-
\d
.
]
/g
,
''
);
}
return
{
x
:
x
,
y
:
y
};
},
_initIndicators
:
function
()
{
var
interactive
=
this
.
options
.
interactiveScrollbars
,
customStyle
=
typeof
this
.
options
.
scrollbars
!=
'
string
'
,
indicators
=
[],
indicator
;
var
that
=
this
;
this
.
indicators
=
[];
if
(
this
.
options
.
scrollbars
)
{
// Vertical scrollbar
if
(
this
.
options
.
scrollY
)
{
indicator
=
{
el
:
createDefaultScrollbar
(
'
v
'
,
interactive
,
this
.
options
.
scrollbars
),
interactive
:
interactive
,
defaultScrollbars
:
true
,
customStyle
:
customStyle
,
resize
:
this
.
options
.
resizeScrollbars
,
shrink
:
this
.
options
.
shrinkScrollbars
,
fade
:
this
.
options
.
fadeScrollbars
,
listenX
:
false
};
this
.
wrapper
.
appendChild
(
indicator
.
el
);
indicators
.
push
(
indicator
);
}
// Horizontal scrollbar
if
(
this
.
options
.
scrollX
)
{
indicator
=
{
el
:
createDefaultScrollbar
(
'
h
'
,
interactive
,
this
.
options
.
scrollbars
),
interactive
:
interactive
,
defaultScrollbars
:
true
,
customStyle
:
customStyle
,
resize
:
this
.
options
.
resizeScrollbars
,
shrink
:
this
.
options
.
shrinkScrollbars
,
fade
:
this
.
options
.
fadeScrollbars
,
listenY
:
false
};
this
.
wrapper
.
appendChild
(
indicator
.
el
);
indicators
.
push
(
indicator
);
}
}
if
(
this
.
options
.
indicators
)
{
// TODO: check concat compatibility
indicators
=
indicators
.
concat
(
this
.
options
.
indicators
);
}
for
(
var
i
=
indicators
.
length
;
i
--
;
)
{
this
.
indicators
.
push
(
new
Indicator
(
this
,
indicators
[
i
])
);
}
// TODO: check if we can use array.map (wide compatibility and performance issues)
function
_indicatorsMap
(
fn
)
{
if
(
that
.
indicators
)
{
for
(
var
i
=
that
.
indicators
.
length
;
i
--
;
)
{
fn
.
call
(
that
.
indicators
[
i
]);
}
}
}
if
(
this
.
options
.
fadeScrollbars
)
{
this
.
on
(
'
scrollEnd
'
,
function
()
{
_indicatorsMap
(
function
()
{
this
.
fade
();
});
});
this
.
on
(
'
scrollCancel
'
,
function
()
{
_indicatorsMap
(
function
()
{
this
.
fade
();
});
});
this
.
on
(
'
scrollStart
'
,
function
()
{
_indicatorsMap
(
function
()
{
this
.
fade
(
1
);
});
});
this
.
on
(
'
beforeScrollStart
'
,
function
()
{
_indicatorsMap
(
function
()
{
this
.
fade
(
1
,
true
);
});
});
}
this
.
on
(
'
refresh
'
,
function
()
{
_indicatorsMap
(
function
()
{
this
.
refresh
();
});
});
this
.
on
(
'
destroy
'
,
function
()
{
_indicatorsMap
(
function
()
{
this
.
destroy
();
});
delete
this
.
indicators
;
});
},
_initWheel
:
function
()
{
utils
.
addEvent
(
this
.
wrapper
,
'
wheel
'
,
this
);
utils
.
addEvent
(
this
.
wrapper
,
'
mousewheel
'
,
this
);
utils
.
addEvent
(
this
.
wrapper
,
'
DOMMouseScroll
'
,
this
);
this
.
on
(
'
destroy
'
,
function
()
{
clearTimeout
(
this
.
wheelTimeout
);
this
.
wheelTimeout
=
null
;
utils
.
removeEvent
(
this
.
wrapper
,
'
wheel
'
,
this
);
utils
.
removeEvent
(
this
.
wrapper
,
'
mousewheel
'
,
this
);
utils
.
removeEvent
(
this
.
wrapper
,
'
DOMMouseScroll
'
,
this
);
});
},
_wheel
:
function
(
e
)
{
if
(
!
this
.
enabled
)
{
return
;
}
e
.
preventDefault
();
var
wheelDeltaX
,
wheelDeltaY
,
newX
,
newY
,
that
=
this
;
if
(
this
.
wheelTimeout
===
undefined
)
{
that
.
_execEvent
(
'
scrollStart
'
);
}
// Execute the scrollEnd event after 400ms the wheel stopped scrolling
clearTimeout
(
this
.
wheelTimeout
);
this
.
wheelTimeout
=
setTimeout
(
function
()
{
if
(
!
that
.
options
.
snap
)
{
that
.
_execEvent
(
'
scrollEnd
'
);
}
that
.
wheelTimeout
=
undefined
;
},
400
);
if
(
'
deltaX
'
in
e
)
{
if
(
e
.
deltaMode
===
1
)
{
wheelDeltaX
=
-
e
.
deltaX
*
this
.
options
.
mouseWheelSpeed
;
wheelDeltaY
=
-
e
.
deltaY
*
this
.
options
.
mouseWheelSpeed
;
}
else
{
wheelDeltaX
=
-
e
.
deltaX
;
wheelDeltaY
=
-
e
.
deltaY
;
}
}
else
if
(
'
wheelDeltaX
'
in
e
)
{
wheelDeltaX
=
e
.
wheelDeltaX
/
120
*
this
.
options
.
mouseWheelSpeed
;
wheelDeltaY
=
e
.
wheelDeltaY
/
120
*
this
.
options
.
mouseWheelSpeed
;
}
else
if
(
'
wheelDelta
'
in
e
)
{
wheelDeltaX
=
wheelDeltaY
=
e
.
wheelDelta
/
120
*
this
.
options
.
mouseWheelSpeed
;
}
else
if
(
'
detail
'
in
e
)
{
wheelDeltaX
=
wheelDeltaY
=
-
e
.
detail
/
3
*
this
.
options
.
mouseWheelSpeed
;
}
else
{
return
;
}
wheelDeltaX
*=
this
.
options
.
invertWheelDirection
;
wheelDeltaY
*=
this
.
options
.
invertWheelDirection
;
if
(
!
this
.
hasVerticalScroll
)
{
wheelDeltaX
=
wheelDeltaY
;
wheelDeltaY
=
0
;
}
if
(
this
.
options
.
snap
)
{
newX
=
this
.
currentPage
.
pageX
;
newY
=
this
.
currentPage
.
pageY
;
if
(
wheelDeltaX
>
0
)
{
newX
--
;
}
else
if
(
wheelDeltaX
<
0
)
{
newX
++
;
}
if
(
wheelDeltaY
>
0
)
{
newY
--
;
}
else
if
(
wheelDeltaY
<
0
)
{
newY
++
;
}
this
.
goToPage
(
newX
,
newY
);
return
;
}
newX
=
this
.
x
+
Math
.
round
(
this
.
hasHorizontalScroll
?
wheelDeltaX
:
0
);
newY
=
this
.
y
+
Math
.
round
(
this
.
hasVerticalScroll
?
wheelDeltaY
:
0
);
this
.
directionX
=
wheelDeltaX
>
0
?
-
1
:
wheelDeltaX
<
0
?
1
:
0
;
this
.
directionY
=
wheelDeltaY
>
0
?
-
1
:
wheelDeltaY
<
0
?
1
:
0
;
if
(
newX
>
0
)
{
newX
=
0
;
}
else
if
(
newX
<
this
.
maxScrollX
)
{
newX
=
this
.
maxScrollX
;
}
if
(
newY
>
0
)
{
newY
=
0
;
}
else
if
(
newY
<
this
.
maxScrollY
)
{
newY
=
this
.
maxScrollY
;
}
this
.
scrollTo
(
newX
,
newY
,
0
);
// INSERT POINT: _wheel
// !!!
this
.
_execEvent
(
'
scroll
'
);
},
_initSnap
:
function
()
{
this
.
currentPage
=
{};
if
(
typeof
this
.
options
.
snap
==
'
string
'
)
{
this
.
options
.
snap
=
this
.
scroller
.
querySelectorAll
(
this
.
options
.
snap
);
}
this
.
on
(
'
refresh
'
,
function
()
{
var
i
=
0
,
l
,
m
=
0
,
n
,
cx
,
cy
,
x
=
0
,
y
,
stepX
=
this
.
options
.
snapStepX
||
this
.
wrapperWidth
,
stepY
=
this
.
options
.
snapStepY
||
this
.
wrapperHeight
,
el
;
this
.
pages
=
[];
if
(
!
this
.
wrapperWidth
||
!
this
.
wrapperHeight
||
!
this
.
scrollerWidth
||
!
this
.
scrollerHeight
)
{
return
;
}
if
(
this
.
options
.
snap
===
true
)
{
cx
=
Math
.
round
(
stepX
/
2
);
cy
=
Math
.
round
(
stepY
/
2
);
while
(
x
>
-
this
.
scrollerWidth
)
{
this
.
pages
[
i
]
=
[];
l
=
0
;
y
=
0
;
while
(
y
>
-
this
.
scrollerHeight
)
{
this
.
pages
[
i
][
l
]
=
{
x
:
Math
.
max
(
x
,
this
.
maxScrollX
),
y
:
Math
.
max
(
y
,
this
.
maxScrollY
),
width
:
stepX
,
height
:
stepY
,
cx
:
x
-
cx
,
cy
:
y
-
cy
};
y
-=
stepY
;
l
++
;
}
x
-=
stepX
;
i
++
;
}
}
else
{
el
=
this
.
options
.
snap
;
l
=
el
.
length
;
n
=
-
1
;
for
(
;
i
<
l
;
i
++
)
{
if
(
i
===
0
||
el
[
i
].
offsetLeft
<=
el
[
i
-
1
].
offsetLeft
)
{
m
=
0
;
n
++
;
}
if
(
!
this
.
pages
[
m
]
)
{
this
.
pages
[
m
]
=
[];
}
x
=
Math
.
max
(
-
el
[
i
].
offsetLeft
,
this
.
maxScrollX
);
y
=
Math
.
max
(
-
el
[
i
].
offsetTop
,
this
.
maxScrollY
);
cx
=
x
-
Math
.
round
(
el
[
i
].
offsetWidth
/
2
);
cy
=
y
-
Math
.
round
(
el
[
i
].
offsetHeight
/
2
);
this
.
pages
[
m
][
n
]
=
{
x
:
x
,
y
:
y
,
width
:
el
[
i
].
offsetWidth
,
height
:
el
[
i
].
offsetHeight
,
cx
:
cx
,
cy
:
cy
};
if
(
x
>
this
.
maxScrollX
)
{
m
++
;
}
}
}
this
.
goToPage
(
this
.
currentPage
.
pageX
||
0
,
this
.
currentPage
.
pageY
||
0
,
0
);
// Update snap threshold if needed
if
(
this
.
options
.
snapThreshold
%
1
===
0
)
{
this
.
snapThresholdX
=
this
.
options
.
snapThreshold
;
this
.
snapThresholdY
=
this
.
options
.
snapThreshold
;
}
else
{
this
.
snapThresholdX
=
Math
.
round
(
this
.
pages
[
this
.
currentPage
.
pageX
][
this
.
currentPage
.
pageY
].
width
*
this
.
options
.
snapThreshold
);
this
.
snapThresholdY
=
Math
.
round
(
this
.
pages
[
this
.
currentPage
.
pageX
][
this
.
currentPage
.
pageY
].
height
*
this
.
options
.
snapThreshold
);
}
});
this
.
on
(
'
flick
'
,
function
()
{
var
time
=
this
.
options
.
snapSpeed
||
Math
.
max
(
Math
.
max
(
Math
.
min
(
Math
.
abs
(
this
.
x
-
this
.
startX
),
1000
),
Math
.
min
(
Math
.
abs
(
this
.
y
-
this
.
startY
),
1000
)
),
300
);
this
.
goToPage
(
this
.
currentPage
.
pageX
+
this
.
directionX
,
this
.
currentPage
.
pageY
+
this
.
directionY
,
time
);
});
},
_nearestSnap
:
function
(
x
,
y
)
{
if
(
!
this
.
pages
.
length
)
{
return
{
x
:
0
,
y
:
0
,
pageX
:
0
,
pageY
:
0
};
}
var
i
=
0
,
l
=
this
.
pages
.
length
,
m
=
0
;
// Check if we exceeded the snap threshold
if
(
Math
.
abs
(
x
-
this
.
absStartX
)
<
this
.
snapThresholdX
&&
Math
.
abs
(
y
-
this
.
absStartY
)
<
this
.
snapThresholdY
)
{
return
this
.
currentPage
;
}
if
(
x
>
0
)
{
x
=
0
;
}
else
if
(
x
<
this
.
maxScrollX
)
{
x
=
this
.
maxScrollX
;
}
if
(
y
>
0
)
{
y
=
0
;
}
else
if
(
y
<
this
.
maxScrollY
)
{
y
=
this
.
maxScrollY
;
}
for
(
;
i
<
l
;
i
++
)
{
if
(
x
>=
this
.
pages
[
i
][
0
].
cx
)
{
x
=
this
.
pages
[
i
][
0
].
x
;
break
;
}
}
l
=
this
.
pages
[
i
].
length
;
for
(
;
m
<
l
;
m
++
)
{
if
(
y
>=
this
.
pages
[
0
][
m
].
cy
)
{
y
=
this
.
pages
[
0
][
m
].
y
;
break
;
}
}
if
(
i
==
this
.
currentPage
.
pageX
)
{
i
+=
this
.
directionX
;
if
(
i
<
0
)
{
i
=
0
;
}
else
if
(
i
>=
this
.
pages
.
length
)
{
i
=
this
.
pages
.
length
-
1
;
}
x
=
this
.
pages
[
i
][
0
].
x
;
}
if
(
m
==
this
.
currentPage
.
pageY
)
{
m
+=
this
.
directionY
;
if
(
m
<
0
)
{
m
=
0
;
}
else
if
(
m
>=
this
.
pages
[
0
].
length
)
{
m
=
this
.
pages
[
0
].
length
-
1
;
}
y
=
this
.
pages
[
0
][
m
].
y
;
}
return
{
x
:
x
,
y
:
y
,
pageX
:
i
,
pageY
:
m
};
},
goToPage
:
function
(
x
,
y
,
time
,
easing
)
{
easing
=
easing
||
this
.
options
.
bounceEasing
;
if
(
x
>=
this
.
pages
.
length
)
{
x
=
this
.
pages
.
length
-
1
;
}
else
if
(
x
<
0
)
{
x
=
0
;
}
if
(
y
>=
this
.
pages
[
x
].
length
)
{
y
=
this
.
pages
[
x
].
length
-
1
;
}
else
if
(
y
<
0
)
{
y
=
0
;
}
var
posX
=
this
.
pages
[
x
][
y
].
x
,
posY
=
this
.
pages
[
x
][
y
].
y
;
time
=
time
===
undefined
?
this
.
options
.
snapSpeed
||
Math
.
max
(
Math
.
max
(
Math
.
min
(
Math
.
abs
(
posX
-
this
.
x
),
1000
),
Math
.
min
(
Math
.
abs
(
posY
-
this
.
y
),
1000
)
),
300
)
:
time
;
this
.
currentPage
=
{
x
:
posX
,
y
:
posY
,
pageX
:
x
,
pageY
:
y
};
this
.
scrollTo
(
posX
,
posY
,
time
,
easing
);
},
next
:
function
(
time
,
easing
)
{
var
x
=
this
.
currentPage
.
pageX
,
y
=
this
.
currentPage
.
pageY
;
x
++
;
if
(
x
>=
this
.
pages
.
length
&&
this
.
hasVerticalScroll
)
{
x
=
0
;
y
++
;
}
this
.
goToPage
(
x
,
y
,
time
,
easing
);
},
prev
:
function
(
time
,
easing
)
{
var
x
=
this
.
currentPage
.
pageX
,
y
=
this
.
currentPage
.
pageY
;
x
--
;
if
(
x
<
0
&&
this
.
hasVerticalScroll
)
{
x
=
0
;
y
--
;
}
this
.
goToPage
(
x
,
y
,
time
,
easing
);
},
_initKeys
:
function
(
e
)
{
// default key bindings
var
keys
=
{
pageUp
:
33
,
pageDown
:
34
,
end
:
35
,
home
:
36
,
left
:
37
,
up
:
38
,
right
:
39
,
down
:
40
};
var
i
;
// if you give me characters I give you keycode
if
(
typeof
this
.
options
.
keyBindings
==
'
object
'
)
{
for
(
i
in
this
.
options
.
keyBindings
)
{
if
(
typeof
this
.
options
.
keyBindings
[
i
]
==
'
string
'
)
{
this
.
options
.
keyBindings
[
i
]
=
this
.
options
.
keyBindings
[
i
].
toUpperCase
().
charCodeAt
(
0
);
}
}
}
else
{
this
.
options
.
keyBindings
=
{};
}
for
(
i
in
keys
)
{
this
.
options
.
keyBindings
[
i
]
=
this
.
options
.
keyBindings
[
i
]
||
keys
[
i
];
}
utils
.
addEvent
(
window
,
'
keydown
'
,
this
);
this
.
on
(
'
destroy
'
,
function
()
{
utils
.
removeEvent
(
window
,
'
keydown
'
,
this
);
});
},
_key
:
function
(
e
)
{
if
(
!
this
.
enabled
)
{
return
;
}
var
snap
=
this
.
options
.
snap
,
// we are using this alot, better to cache it
newX
=
snap
?
this
.
currentPage
.
pageX
:
this
.
x
,
newY
=
snap
?
this
.
currentPage
.
pageY
:
this
.
y
,
now
=
utils
.
getTime
(),
prevTime
=
this
.
keyTime
||
0
,
acceleration
=
0.250
,
pos
;
if
(
this
.
options
.
useTransition
&&
this
.
isInTransition
)
{
pos
=
this
.
getComputedPosition
();
this
.
_translate
(
Math
.
round
(
pos
.
x
),
Math
.
round
(
pos
.
y
));
this
.
isInTransition
=
false
;
}
this
.
keyAcceleration
=
now
-
prevTime
<
200
?
Math
.
min
(
this
.
keyAcceleration
+
acceleration
,
50
)
:
0
;
switch
(
e
.
keyCode
)
{
case
this
.
options
.
keyBindings
.
pageUp
:
if
(
this
.
hasHorizontalScroll
&&
!
this
.
hasVerticalScroll
)
{
newX
+=
snap
?
1
:
this
.
wrapperWidth
;
}
else
{
newY
+=
snap
?
1
:
this
.
wrapperHeight
;
}
break
;
case
this
.
options
.
keyBindings
.
pageDown
:
if
(
this
.
hasHorizontalScroll
&&
!
this
.
hasVerticalScroll
)
{
newX
-=
snap
?
1
:
this
.
wrapperWidth
;
}
else
{
newY
-=
snap
?
1
:
this
.
wrapperHeight
;
}
break
;
case
this
.
options
.
keyBindings
.
end
:
newX
=
snap
?
this
.
pages
.
length
-
1
:
this
.
maxScrollX
;
newY
=
snap
?
this
.
pages
[
0
].
length
-
1
:
this
.
maxScrollY
;
break
;
case
this
.
options
.
keyBindings
.
home
:
newX
=
0
;
newY
=
0
;
break
;
case
this
.
options
.
keyBindings
.
left
:
newX
+=
snap
?
-
1
:
5
+
this
.
keyAcceleration
>>
0
;
break
;
case
this
.
options
.
keyBindings
.
up
:
newY
+=
snap
?
1
:
5
+
this
.
keyAcceleration
>>
0
;
break
;
case
this
.
options
.
keyBindings
.
right
:
newX
-=
snap
?
-
1
:
5
+
this
.
keyAcceleration
>>
0
;
break
;
case
this
.
options
.
keyBindings
.
down
:
newY
-=
snap
?
1
:
5
+
this
.
keyAcceleration
>>
0
;
break
;
default
:
return
;
}
if
(
snap
)
{
this
.
goToPage
(
newX
,
newY
);
return
;
}
if
(
newX
>
0
)
{
newX
=
0
;
this
.
keyAcceleration
=
0
;
}
else
if
(
newX
<
this
.
maxScrollX
)
{
newX
=
this
.
maxScrollX
;
this
.
keyAcceleration
=
0
;
}
if
(
newY
>
0
)
{
newY
=
0
;
this
.
keyAcceleration
=
0
;
}
else
if
(
newY
<
this
.
maxScrollY
)
{
newY
=
this
.
maxScrollY
;
this
.
keyAcceleration
=
0
;
}
this
.
scrollTo
(
newX
,
newY
,
0
);
this
.
keyTime
=
now
;
},
_animate
:
function
(
destX
,
destY
,
duration
,
easingFn
)
{
var
that
=
this
,
startX
=
this
.
x
,
startY
=
this
.
y
,
startTime
=
utils
.
getTime
(),
destTime
=
startTime
+
duration
;
function
step
()
{
var
now
=
utils
.
getTime
(),
newX
,
newY
,
easing
;
if
(
now
>=
destTime
)
{
that
.
isAnimating
=
false
;
that
.
_translate
(
destX
,
destY
);
if
(
!
that
.
resetPosition
(
that
.
options
.
bounceTime
)
)
{
that
.
_execEvent
(
'
scrollEnd
'
);
}
return
;
}
now
=
(
now
-
startTime
)
/
duration
;
easing
=
easingFn
(
now
);
newX
=
(
destX
-
startX
)
*
easing
+
startX
;
newY
=
(
destY
-
startY
)
*
easing
+
startY
;
that
.
_translate
(
newX
,
newY
);
if
(
that
.
isAnimating
)
{
rAF
(
step
);
}
// !!!
that
.
_execEvent
(
'
scroll
'
);
}
this
.
isAnimating
=
true
;
step
();
},
handleEvent
:
function
(
e
)
{
switch
(
e
.
type
)
{
case
'
touchstart
'
:
case
'
pointerdown
'
:
case
'
MSPointerDown
'
:
case
'
mousedown
'
:
this
.
_start
(
e
);
break
;
case
'
touchmove
'
:
case
'
pointermove
'
:
case
'
MSPointerMove
'
:
case
'
mousemove
'
:
this
.
_move
(
e
);
break
;
case
'
touchend
'
:
case
'
pointerup
'
:
case
'
MSPointerUp
'
:
case
'
mouseup
'
:
case
'
touchcancel
'
:
case
'
pointercancel
'
:
case
'
MSPointerCancel
'
:
case
'
mousecancel
'
:
this
.
_end
(
e
);
break
;
case
'
orientationchange
'
:
case
'
resize
'
:
this
.
_resize
();
break
;
case
'
transitionend
'
:
case
'
webkitTransitionEnd
'
:
case
'
oTransitionEnd
'
:
case
'
MSTransitionEnd
'
:
this
.
_transitionEnd
(
e
);
break
;
case
'
wheel
'
:
case
'
DOMMouseScroll
'
:
case
'
mousewheel
'
:
this
.
_wheel
(
e
);
break
;
case
'
keydown
'
:
this
.
_key
(
e
);
break
;
case
'
click
'
:
if
(
this
.
enabled
&&
!
e
.
_constructed
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
}
break
;
}
}
};
function
createDefaultScrollbar
(
direction
,
interactive
,
type
)
{
var
scrollbar
=
document
.
createElement
(
'
div
'
),
indicator
=
document
.
createElement
(
'
div
'
);
if
(
type
===
true
)
{
scrollbar
.
style
.
cssText
=
'
position:absolute;z-index:9999
'
;
indicator
.
style
.
cssText
=
'
-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px
'
;
}
indicator
.
className
=
'
iScrollIndicator
'
;
if
(
direction
==
'
h
'
)
{
if
(
type
===
true
)
{
scrollbar
.
style
.
cssText
+=
'
;height:7px;left:2px;right:2px;bottom:0
'
;
indicator
.
style
.
height
=
'
100%
'
;
}
scrollbar
.
className
=
'
iScrollHorizontalScrollbar
'
;
}
else
{
if
(
type
===
true
)
{
scrollbar
.
style
.
cssText
+=
'
;width:7px;bottom:2px;top:2px;right:1px
'
;
indicator
.
style
.
width
=
'
100%
'
;
}
scrollbar
.
className
=
'
iScrollVerticalScrollbar
'
;
}
scrollbar
.
style
.
cssText
+=
'
;overflow:hidden
'
;
if
(
!
interactive
)
{
scrollbar
.
style
.
pointerEvents
=
'
none
'
;
}
scrollbar
.
appendChild
(
indicator
);
return
scrollbar
;
}
function
Indicator
(
scroller
,
options
)
{
this
.
wrapper
=
typeof
options
.
el
==
'
string
'
?
document
.
querySelector
(
options
.
el
)
:
options
.
el
;
this
.
wrapperStyle
=
this
.
wrapper
.
style
;
this
.
indicator
=
this
.
wrapper
.
children
[
0
];
this
.
indicatorStyle
=
this
.
indicator
.
style
;
this
.
scroller
=
scroller
;
this
.
options
=
{
listenX
:
true
,
listenY
:
true
,
interactive
:
false
,
resize
:
true
,
defaultScrollbars
:
false
,
shrink
:
false
,
fade
:
false
,
speedRatioX
:
0
,
speedRatioY
:
0
};
for
(
var
i
in
options
)
{
this
.
options
[
i
]
=
options
[
i
];
}
this
.
sizeRatioX
=
1
;
this
.
sizeRatioY
=
1
;
this
.
maxPosX
=
0
;
this
.
maxPosY
=
0
;
if
(
this
.
options
.
interactive
)
{
if
(
!
this
.
options
.
disableTouch
)
{
utils
.
addEvent
(
this
.
indicator
,
'
touchstart
'
,
this
);
utils
.
addEvent
(
window
,
'
touchend
'
,
this
);
}
if
(
!
this
.
options
.
disablePointer
)
{
utils
.
addEvent
(
this
.
indicator
,
utils
.
prefixPointerEvent
(
'
pointerdown
'
),
this
);
utils
.
addEvent
(
window
,
utils
.
prefixPointerEvent
(
'
pointerup
'
),
this
);
}
if
(
!
this
.
options
.
disableMouse
)
{
utils
.
addEvent
(
this
.
indicator
,
'
mousedown
'
,
this
);
utils
.
addEvent
(
window
,
'
mouseup
'
,
this
);
}
}
if
(
this
.
options
.
fade
)
{
this
.
wrapperStyle
[
utils
.
style
.
transform
]
=
this
.
scroller
.
translateZ
;
var
durationProp
=
utils
.
style
.
transitionDuration
;
if
(
!
durationProp
)
{
return
;
}
this
.
wrapperStyle
[
durationProp
]
=
utils
.
isBadAndroid
?
'
0.0001ms
'
:
'
0ms
'
;
// remove 0.0001ms
var
self
=
this
;
if
(
utils
.
isBadAndroid
)
{
rAF
(
function
()
{
if
(
self
.
wrapperStyle
[
durationProp
]
===
'
0.0001ms
'
)
{
self
.
wrapperStyle
[
durationProp
]
=
'
0s
'
;
}
});
}
this
.
wrapperStyle
.
opacity
=
'
0
'
;
}
}
}
dummyStyle
=
null
;
// for the sake of it
Indicator
.
prototype
=
{
handleEvent
:
function
(
e
)
{
//---------------------------------------------------------export---------------------------------------------------
switch
(
e
.
type
)
{
window
[
'
AscCommon
'
]
=
window
[
'
AscCommon
'
]
||
{};
case
'
touchstart
'
:
window
[
"
AscCommon
"
].
CTouchScroll
=
CTouchScroll
;
case
'
pointerdown
'
:
case
'
MSPointerDown
'
:
case
'
mousedown
'
:
this
.
_start
(
e
);
break
;
case
'
touchmove
'
:
case
'
pointermove
'
:
case
'
MSPointerMove
'
:
case
'
mousemove
'
:
this
.
_move
(
e
);
break
;
case
'
touchend
'
:
case
'
pointerup
'
:
case
'
MSPointerUp
'
:
case
'
mouseup
'
:
case
'
touchcancel
'
:
case
'
pointercancel
'
:
case
'
MSPointerCancel
'
:
case
'
mousecancel
'
:
this
.
_end
(
e
);
break
;
}
},
destroy
:
function
()
{
if
(
this
.
options
.
fadeScrollbars
)
{
clearTimeout
(
this
.
fadeTimeout
);
this
.
fadeTimeout
=
null
;
}
if
(
this
.
options
.
interactive
)
{
utils
.
removeEvent
(
this
.
indicator
,
'
touchstart
'
,
this
);
utils
.
removeEvent
(
this
.
indicator
,
utils
.
prefixPointerEvent
(
'
pointerdown
'
),
this
);
utils
.
removeEvent
(
this
.
indicator
,
'
mousedown
'
,
this
);
utils
.
removeEvent
(
window
,
'
touchmove
'
,
this
);
utils
.
removeEvent
(
window
,
utils
.
prefixPointerEvent
(
'
pointermove
'
),
this
);
utils
.
removeEvent
(
window
,
'
mousemove
'
,
this
);
utils
.
removeEvent
(
window
,
'
touchend
'
,
this
);
utils
.
removeEvent
(
window
,
utils
.
prefixPointerEvent
(
'
pointerup
'
),
this
);
utils
.
removeEvent
(
window
,
'
mouseup
'
,
this
);
}
if
(
this
.
options
.
defaultScrollbars
)
{
this
.
wrapper
.
parentNode
.
removeChild
(
this
.
wrapper
);
}
},
_start
:
function
(
e
)
{
var
point
=
e
.
touches
?
e
.
touches
[
0
]
:
e
;
e
.
preventDefault
();
e
.
stopPropagation
();
this
.
transitionTime
();
this
.
initiated
=
true
;
this
.
moved
=
false
;
this
.
lastPointX
=
point
.
pageX
;
this
.
lastPointY
=
point
.
pageY
;
this
.
startTime
=
utils
.
getTime
();
if
(
!
this
.
options
.
disableTouch
)
{
utils
.
addEvent
(
window
,
'
touchmove
'
,
this
);
}
if
(
!
this
.
options
.
disablePointer
)
{
utils
.
addEvent
(
window
,
utils
.
prefixPointerEvent
(
'
pointermove
'
),
this
);
}
if
(
!
this
.
options
.
disableMouse
)
{
utils
.
addEvent
(
window
,
'
mousemove
'
,
this
);
}
this
.
scroller
.
_execEvent
(
'
beforeScrollStart
'
);
},
_move
:
function
(
e
)
{
var
point
=
e
.
touches
?
e
.
touches
[
0
]
:
e
,
deltaX
,
deltaY
,
newX
,
newY
,
timestamp
=
utils
.
getTime
();
if
(
!
this
.
moved
)
{
this
.
scroller
.
_execEvent
(
'
scrollStart
'
);
}
this
.
moved
=
true
;
deltaX
=
point
.
pageX
-
this
.
lastPointX
;
this
.
lastPointX
=
point
.
pageX
;
deltaY
=
point
.
pageY
-
this
.
lastPointY
;
this
.
lastPointY
=
point
.
pageY
;
newX
=
this
.
x
+
deltaX
;
newY
=
this
.
y
+
deltaY
;
this
.
_pos
(
newX
,
newY
);
// INSERT POINT: indicator._move
e
.
preventDefault
();
e
.
stopPropagation
();
// !!!
this
.
_execEvent
(
'
scroll
'
);
},
_end
:
function
(
e
)
{
if
(
!
this
.
initiated
)
{
return
;
}
this
.
initiated
=
false
;
e
.
preventDefault
();
e
.
stopPropagation
();
utils
.
removeEvent
(
window
,
'
touchmove
'
,
this
);
utils
.
removeEvent
(
window
,
utils
.
prefixPointerEvent
(
'
pointermove
'
),
this
);
utils
.
removeEvent
(
window
,
'
mousemove
'
,
this
);
if
(
this
.
scroller
.
options
.
snap
)
{
var
snap
=
this
.
scroller
.
_nearestSnap
(
this
.
scroller
.
x
,
this
.
scroller
.
y
);
var
time
=
this
.
options
.
snapSpeed
||
Math
.
max
(
Math
.
max
(
Math
.
min
(
Math
.
abs
(
this
.
scroller
.
x
-
snap
.
x
),
1000
),
Math
.
min
(
Math
.
abs
(
this
.
scroller
.
y
-
snap
.
y
),
1000
)
),
300
);
if
(
this
.
scroller
.
x
!=
snap
.
x
||
this
.
scroller
.
y
!=
snap
.
y
)
{
this
.
scroller
.
directionX
=
0
;
this
.
scroller
.
directionY
=
0
;
this
.
scroller
.
currentPage
=
snap
;
this
.
scroller
.
scrollTo
(
snap
.
x
,
snap
.
y
,
time
,
this
.
scroller
.
options
.
bounceEasing
);
}
}
if
(
this
.
moved
)
{
this
.
scroller
.
_execEvent
(
'
scrollEnd
'
);
}
},
transitionTime
:
function
(
time
)
{
time
=
time
||
0
;
var
durationProp
=
utils
.
style
.
transitionDuration
;
if
(
!
durationProp
)
{
return
;
}
this
.
indicatorStyle
[
durationProp
]
=
time
+
'
ms
'
;
if
(
!
time
&&
utils
.
isBadAndroid
)
{
this
.
indicatorStyle
[
durationProp
]
=
'
0.0001ms
'
;
// remove 0.0001ms
var
self
=
this
;
rAF
(
function
()
{
if
(
self
.
indicatorStyle
[
durationProp
]
===
'
0.0001ms
'
)
{
self
.
indicatorStyle
[
durationProp
]
=
'
0s
'
;
}
});
}
},
transitionTimingFunction
:
function
(
easing
)
{
this
.
indicatorStyle
[
utils
.
style
.
transitionTimingFunction
]
=
easing
;
},
refresh
:
function
()
{
this
.
transitionTime
();
if
(
this
.
options
.
listenX
&&
!
this
.
options
.
listenY
)
{
this
.
indicatorStyle
.
display
=
this
.
scroller
.
hasHorizontalScroll
?
'
block
'
:
'
none
'
;
}
else
if
(
this
.
options
.
listenY
&&
!
this
.
options
.
listenX
)
{
this
.
indicatorStyle
.
display
=
this
.
scroller
.
hasVerticalScroll
?
'
block
'
:
'
none
'
;
}
else
{
this
.
indicatorStyle
.
display
=
this
.
scroller
.
hasHorizontalScroll
||
this
.
scroller
.
hasVerticalScroll
?
'
block
'
:
'
none
'
;
}
if
(
this
.
scroller
.
hasHorizontalScroll
&&
this
.
scroller
.
hasVerticalScroll
)
{
utils
.
addClass
(
this
.
wrapper
,
'
iScrollBothScrollbars
'
);
utils
.
removeClass
(
this
.
wrapper
,
'
iScrollLoneScrollbar
'
);
if
(
this
.
options
.
defaultScrollbars
&&
this
.
options
.
customStyle
)
{
if
(
this
.
options
.
listenX
)
{
this
.
wrapper
.
style
.
right
=
'
8px
'
;
}
else
{
this
.
wrapper
.
style
.
bottom
=
'
8px
'
;
}
}
}
else
{
utils
.
removeClass
(
this
.
wrapper
,
'
iScrollBothScrollbars
'
);
utils
.
addClass
(
this
.
wrapper
,
'
iScrollLoneScrollbar
'
);
if
(
this
.
options
.
defaultScrollbars
&&
this
.
options
.
customStyle
)
{
if
(
this
.
options
.
listenX
)
{
this
.
wrapper
.
style
.
right
=
'
2px
'
;
}
else
{
this
.
wrapper
.
style
.
bottom
=
'
2px
'
;
}
}
}
var
r
=
this
.
wrapper
.
offsetHeight
;
// force refresh
if
(
this
.
options
.
listenX
)
{
this
.
wrapperWidth
=
this
.
wrapper
.
clientWidth
;
if
(
this
.
options
.
resize
)
{
this
.
indicatorWidth
=
Math
.
max
(
Math
.
round
(
this
.
wrapperWidth
*
this
.
wrapperWidth
/
(
this
.
scroller
.
scrollerWidth
||
this
.
wrapperWidth
||
1
)),
8
);
this
.
indicatorStyle
.
width
=
this
.
indicatorWidth
+
'
px
'
;
}
else
{
this
.
indicatorWidth
=
this
.
indicator
.
clientWidth
;
}
this
.
maxPosX
=
this
.
wrapperWidth
-
this
.
indicatorWidth
;
if
(
this
.
options
.
shrink
==
'
clip
'
)
{
this
.
minBoundaryX
=
-
this
.
indicatorWidth
+
8
;
this
.
maxBoundaryX
=
this
.
wrapperWidth
-
8
;
}
else
{
this
.
minBoundaryX
=
0
;
this
.
maxBoundaryX
=
this
.
maxPosX
;
}
this
.
sizeRatioX
=
this
.
options
.
speedRatioX
||
(
this
.
scroller
.
maxScrollX
&&
(
this
.
maxPosX
/
this
.
scroller
.
maxScrollX
));
}
if
(
this
.
options
.
listenY
)
{
this
.
wrapperHeight
=
this
.
wrapper
.
clientHeight
;
if
(
this
.
options
.
resize
)
{
this
.
indicatorHeight
=
Math
.
max
(
Math
.
round
(
this
.
wrapperHeight
*
this
.
wrapperHeight
/
(
this
.
scroller
.
scrollerHeight
||
this
.
wrapperHeight
||
1
)),
8
);
this
.
indicatorStyle
.
height
=
this
.
indicatorHeight
+
'
px
'
;
}
else
{
this
.
indicatorHeight
=
this
.
indicator
.
clientHeight
;
}
this
.
maxPosY
=
this
.
wrapperHeight
-
this
.
indicatorHeight
;
if
(
this
.
options
.
shrink
==
'
clip
'
)
{
this
.
minBoundaryY
=
-
this
.
indicatorHeight
+
8
;
this
.
maxBoundaryY
=
this
.
wrapperHeight
-
8
;
}
else
{
this
.
minBoundaryY
=
0
;
this
.
maxBoundaryY
=
this
.
maxPosY
;
}
this
.
maxPosY
=
this
.
wrapperHeight
-
this
.
indicatorHeight
;
this
.
sizeRatioY
=
this
.
options
.
speedRatioY
||
(
this
.
scroller
.
maxScrollY
&&
(
this
.
maxPosY
/
this
.
scroller
.
maxScrollY
));
}
this
.
updatePosition
();
},
updatePosition
:
function
()
{
var
x
=
this
.
options
.
listenX
&&
Math
.
round
(
this
.
sizeRatioX
*
this
.
scroller
.
x
)
||
0
,
y
=
this
.
options
.
listenY
&&
Math
.
round
(
this
.
sizeRatioY
*
this
.
scroller
.
y
)
||
0
;
if
(
!
this
.
options
.
ignoreBoundaries
)
{
if
(
x
<
this
.
minBoundaryX
)
{
if
(
this
.
options
.
shrink
==
'
scale
'
)
{
this
.
width
=
Math
.
max
(
this
.
indicatorWidth
+
x
,
8
);
this
.
indicatorStyle
.
width
=
this
.
width
+
'
px
'
;
}
x
=
this
.
minBoundaryX
;
}
else
if
(
x
>
this
.
maxBoundaryX
)
{
if
(
this
.
options
.
shrink
==
'
scale
'
)
{
this
.
width
=
Math
.
max
(
this
.
indicatorWidth
-
(
x
-
this
.
maxPosX
),
8
);
this
.
indicatorStyle
.
width
=
this
.
width
+
'
px
'
;
x
=
this
.
maxPosX
+
this
.
indicatorWidth
-
this
.
width
;
}
else
{
x
=
this
.
maxBoundaryX
;
}
}
else
if
(
this
.
options
.
shrink
==
'
scale
'
&&
this
.
width
!=
this
.
indicatorWidth
)
{
this
.
width
=
this
.
indicatorWidth
;
this
.
indicatorStyle
.
width
=
this
.
width
+
'
px
'
;
}
if
(
y
<
this
.
minBoundaryY
)
{
if
(
this
.
options
.
shrink
==
'
scale
'
)
{
this
.
height
=
Math
.
max
(
this
.
indicatorHeight
+
y
*
3
,
8
);
this
.
indicatorStyle
.
height
=
this
.
height
+
'
px
'
;
}
y
=
this
.
minBoundaryY
;
}
else
if
(
y
>
this
.
maxBoundaryY
)
{
if
(
this
.
options
.
shrink
==
'
scale
'
)
{
this
.
height
=
Math
.
max
(
this
.
indicatorHeight
-
(
y
-
this
.
maxPosY
)
*
3
,
8
);
this
.
indicatorStyle
.
height
=
this
.
height
+
'
px
'
;
y
=
this
.
maxPosY
+
this
.
indicatorHeight
-
this
.
height
;
}
else
{
y
=
this
.
maxBoundaryY
;
}
}
else
if
(
this
.
options
.
shrink
==
'
scale
'
&&
this
.
height
!=
this
.
indicatorHeight
)
{
this
.
height
=
this
.
indicatorHeight
;
this
.
indicatorStyle
.
height
=
this
.
height
+
'
px
'
;
}
}
this
.
x
=
x
;
this
.
y
=
y
;
if
(
this
.
scroller
.
options
.
useTransform
)
{
this
.
indicatorStyle
[
utils
.
style
.
transform
]
=
'
translate(
'
+
x
+
'
px,
'
+
y
+
'
px)
'
+
this
.
scroller
.
translateZ
;
}
else
{
this
.
indicatorStyle
.
left
=
x
+
'
px
'
;
this
.
indicatorStyle
.
top
=
y
+
'
px
'
;
}
},
_pos
:
function
(
x
,
y
)
{
if
(
x
<
0
)
{
x
=
0
;
}
else
if
(
x
>
this
.
maxPosX
)
{
x
=
this
.
maxPosX
;
}
if
(
y
<
0
)
{
y
=
0
;
}
else
if
(
y
>
this
.
maxPosY
)
{
y
=
this
.
maxPosY
;
}
x
=
this
.
options
.
listenX
?
Math
.
round
(
x
/
this
.
sizeRatioX
)
:
this
.
scroller
.
x
;
y
=
this
.
options
.
listenY
?
Math
.
round
(
y
/
this
.
sizeRatioY
)
:
this
.
scroller
.
y
;
this
.
scroller
.
scrollTo
(
x
,
y
);
},
fade
:
function
(
val
,
hold
)
{
if
(
hold
&&
!
this
.
visible
)
{
return
;
}
clearTimeout
(
this
.
fadeTimeout
);
this
.
fadeTimeout
=
null
;
var
time
=
val
?
250
:
500
,
delay
=
val
?
0
:
300
;
val
=
val
?
'
1
'
:
'
0
'
;
this
.
wrapperStyle
[
utils
.
style
.
transitionDuration
]
=
time
+
'
ms
'
;
this
.
fadeTimeout
=
setTimeout
((
function
(
val
)
{
this
.
wrapperStyle
.
opacity
=
val
;
this
.
visible
=
+
val
;
}).
bind
(
this
,
val
),
delay
);
}
};
IScroll
.
utils
=
utils
;
if
(
typeof
module
!=
'
undefined
'
&&
module
.
exports
)
{
module
.
exports
=
IScroll
;
}
else
if
(
typeof
define
==
'
function
'
&&
define
.
amd
)
{
define
(
function
()
{
return
IScroll
;
}
);
}
else
{
window
.
IScroll
=
IScroll
;
}
})(
window
,
document
);
})(
window
,
document
,
Math
);
word/Drawing/HtmlPage.js
View file @
ae3cf693
...
@@ -798,6 +798,9 @@ function CEditorPage(api)
...
@@ -798,6 +798,9 @@ function CEditorPage(api)
{
{
this
.
TextBoxBackground
.
HtmlElement
[
"
ontouchcancel
"
]
=
function
(
e
)
this
.
TextBoxBackground
.
HtmlElement
[
"
ontouchcancel
"
]
=
function
(
e
)
{
{
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchEnd
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchEnd
(
e
);
...
@@ -814,6 +817,9 @@ function CEditorPage(api)
...
@@ -814,6 +817,9 @@ function CEditorPage(api)
if
(
!
oThis
.
IsFocus
)
if
(
!
oThis
.
IsFocus
)
oThis
.
m_oApi
.
asc_enableKeyEvents
(
true
);
oThis
.
m_oApi
.
asc_enableKeyEvents
(
true
);
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchStart
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchStart
(
e
);
...
@@ -823,6 +829,9 @@ function CEditorPage(api)
...
@@ -823,6 +829,9 @@ function CEditorPage(api)
};
};
this
.
TextBoxBackground
.
HtmlElement
[
"
ontouchmove
"
]
=
function
(
e
)
this
.
TextBoxBackground
.
HtmlElement
[
"
ontouchmove
"
]
=
function
(
e
)
{
{
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchMove
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchMove
(
e
);
...
@@ -832,6 +841,9 @@ function CEditorPage(api)
...
@@ -832,6 +841,9 @@ function CEditorPage(api)
};
};
this
.
TextBoxBackground
.
HtmlElement
[
"
ontouchend
"
]
=
function
(
e
)
this
.
TextBoxBackground
.
HtmlElement
[
"
ontouchend
"
]
=
function
(
e
)
{
{
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchEnd
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchEnd
(
e
);
...
@@ -847,6 +859,9 @@ function CEditorPage(api)
...
@@ -847,6 +859,9 @@ function CEditorPage(api)
if
(
AscCommon
.
g_inputContext
)
if
(
AscCommon
.
g_inputContext
)
AscCommon
.
g_inputContext
.
externalChangeFocus
();
AscCommon
.
g_inputContext
.
externalChangeFocus
();
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchStart
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchStart
(
e
);
...
@@ -856,6 +871,9 @@ function CEditorPage(api)
...
@@ -856,6 +871,9 @@ function CEditorPage(api)
};
};
this
.
TextBoxBackground
.
HtmlElement
[
"
onmousemove
"
]
=
function
(
e
)
this
.
TextBoxBackground
.
HtmlElement
[
"
onmousemove
"
]
=
function
(
e
)
{
{
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchMove
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchMove
(
e
);
...
@@ -865,6 +883,9 @@ function CEditorPage(api)
...
@@ -865,6 +883,9 @@ function CEditorPage(api)
};
};
this
.
TextBoxBackground
.
HtmlElement
[
"
onmouseup
"
]
=
function
(
e
)
this
.
TextBoxBackground
.
HtmlElement
[
"
onmouseup
"
]
=
function
(
e
)
{
{
if
(
!
oThis
.
MobileTouchManager
)
return
false
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
IsUpdateOverlayOnlyEndReturn
=
true
;
oThis
.
StartUpdateOverlay
();
oThis
.
StartUpdateOverlay
();
var
ret
=
oThis
.
MobileTouchManager
.
onTouchEnd
(
e
);
var
ret
=
oThis
.
MobileTouchManager
.
onTouchEnd
(
e
);
...
@@ -2250,6 +2271,12 @@ function CEditorPage(api)
...
@@ -2250,6 +2271,12 @@ function CEditorPage(api)
this
.
ReaderModeDiv
=
document
.
getElementById
(
"
reader_id
"
);
this
.
ReaderModeDiv
=
document
.
getElementById
(
"
reader_id
"
);
if
(
this
.
MobileTouchManager
)
{
this
.
MobileTouchManager
.
Destroy
();
this
.
MobileTouchManager
=
null
;
}
this
.
ReaderTouchManager
=
new
AscCommon
.
CReaderTouchManager
();
this
.
ReaderTouchManager
=
new
AscCommon
.
CReaderTouchManager
();
this
.
ReaderTouchManager
.
Init
(
this
);
this
.
ReaderTouchManager
.
Init
(
this
);
...
@@ -2324,6 +2351,12 @@ function CEditorPage(api)
...
@@ -2324,6 +2351,12 @@ function CEditorPage(api)
oThis
.
ReaderModeCurrent
=
0
;
oThis
.
ReaderModeCurrent
=
0
;
if
(
oThis
.
m_oApi
.
isMobileVersion
)
{
oThis
.
MobileTouchManager
=
new
AscCommon
.
CMobileTouchManager
();
oThis
.
MobileTouchManager
.
Init
(
oThis
);
}
return
;
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment