1
1
/*!
2
- * Viewer.js v1.3.1
2
+ * Viewer.js v1.3.2
3
3
* https://fengyuanchen.github.io/viewerjs
4
4
*
5
5
* Copyright 2015-present Chen Fengyuan
6
6
* Released under the MIT license
7
7
*
8
- * Date: 2018-12-09T07:48:29.436Z
8
+ * Date: 2019-01-24T11:01:33.473Z
9
9
*/
10
10
11
11
'use strict' ;
@@ -294,7 +294,7 @@ var EVENT_SHOWN = 'shown';
294
294
var EVENT_TRANSITION_END = 'transitionend' ;
295
295
var EVENT_VIEW = 'view' ;
296
296
var EVENT_VIEWED = 'viewed' ;
297
- var EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll ' ;
297
+ var EVENT_WHEEL = 'wheel' ;
298
298
var EVENT_ZOOM = 'zoom' ;
299
299
var EVENT_ZOOMED = 'zoomed' ; // Data keys
300
300
@@ -1085,6 +1085,7 @@ var render = {
1085
1085
setStyle ( image , assign ( {
1086
1086
width : imageData . width ,
1087
1087
height : imageData . height ,
1088
+ // XXX: Not to use translateX/Y to avoid image shaking when zooming
1088
1089
marginLeft : imageData . left ,
1089
1090
marginTop : imageData . top
1090
1091
} , getTransforms ( imageData ) ) ) ;
@@ -1131,7 +1132,10 @@ var events = {
1131
1132
canvas = this . canvas ;
1132
1133
var document = this . element . ownerDocument ;
1133
1134
addListener ( viewer , EVENT_CLICK , this . onClick = this . click . bind ( this ) ) ;
1134
- addListener ( viewer , EVENT_WHEEL , this . onWheel = this . wheel . bind ( this ) ) ;
1135
+ addListener ( viewer , EVENT_WHEEL , this . onWheel = this . wheel . bind ( this ) , {
1136
+ passive : false ,
1137
+ capture : true
1138
+ } ) ;
1135
1139
addListener ( viewer , EVENT_DRAG_START , this . onDragStart = this . dragstart . bind ( this ) ) ;
1136
1140
addListener ( canvas , EVENT_POINTER_DOWN , this . onPointerDown = this . pointerdown . bind ( this ) ) ;
1137
1141
addListener ( document , EVENT_POINTER_MOVE , this . onPointerMove = this . pointermove . bind ( this ) ) ;
@@ -1149,7 +1153,10 @@ var events = {
1149
1153
canvas = this . canvas ;
1150
1154
var document = this . element . ownerDocument ;
1151
1155
removeListener ( viewer , EVENT_CLICK , this . onClick ) ;
1152
- removeListener ( viewer , EVENT_WHEEL , this . onWheel ) ;
1156
+ removeListener ( viewer , EVENT_WHEEL , this . onWheel , {
1157
+ passive : false ,
1158
+ capture : true
1159
+ } ) ;
1153
1160
removeListener ( viewer , EVENT_DRAG_START , this . onDragStart ) ;
1154
1161
removeListener ( canvas , EVENT_POINTER_DOWN , this . onPointerDown ) ;
1155
1162
removeListener ( document , EVENT_POINTER_MOVE , this . onPointerMove ) ;
@@ -1418,9 +1425,9 @@ var handlers = {
1418
1425
var buttons = event . buttons ,
1419
1426
button = event . button ;
1420
1427
1421
- if ( ! this . viewed || this . showing || this . viewing || this . hiding // No primary button (usually the left button)
1422
- // Note: Touch events does not contain `buttons` and `button` properties
1423
- || isNumber ( buttons ) && buttons > 1 || isNumber ( button ) && button > 0 // Open context menu
1428
+ if ( ! this . viewed || this . showing || this . viewing || this . hiding // No primary button (Usually the left button)
1429
+ // Note that touch events have no `buttons` or `button` property
1430
+ || isNumber ( buttons ) && buttons !== 1 || isNumber ( button ) && button !== 0 // Open context menu
1424
1431
|| event . ctrlKey ) {
1425
1432
return ;
1426
1433
} // Prevent default behaviours as page zooming in touch devices.
@@ -1549,7 +1556,7 @@ var handlers = {
1549
1556
}
1550
1557
1551
1558
if ( this . played ) {
1552
- if ( this . options . fullscreen && this . fulled && ! document . fullscreenElement && ! document . mozFullScreenElement && ! document . webkitFullscreenElement && ! document . msFullscreenElement ) {
1559
+ if ( this . options . fullscreen && this . fulled && ! ( document . fullscreenElement || document . webkitFullscreenElement || document . mozFullScreenElement || document . msFullscreenElement ) ) {
1553
1560
this . stop ( ) ;
1554
1561
return ;
1555
1562
}
@@ -2596,32 +2603,33 @@ var others = {
2596
2603
requestFullscreen : function requestFullscreen ( ) {
2597
2604
var document = this . element . ownerDocument ;
2598
2605
2599
- if ( this . fulled && ! document . fullscreenElement && ! document . mozFullScreenElement && ! document . webkitFullscreenElement && ! document . msFullscreenElement ) {
2600
- var documentElement = document . documentElement ;
2606
+ if ( this . fulled && ! ( document . fullscreenElement || document . webkitFullscreenElement || document . mozFullScreenElement || document . msFullscreenElement ) ) {
2607
+ var documentElement = document . documentElement ; // Element.requestFullscreen()
2601
2608
2602
2609
if ( documentElement . requestFullscreen ) {
2603
2610
documentElement . requestFullscreen ( ) ;
2604
- } else if ( documentElement . msRequestFullscreen ) {
2605
- documentElement . msRequestFullscreen ( ) ;
2606
- } else if ( documentElement . mozRequestFullScreen ) {
2607
- documentElement . mozRequestFullScreen ( ) ;
2608
2611
} else if ( documentElement . webkitRequestFullscreen ) {
2609
2612
documentElement . webkitRequestFullscreen ( Element . ALLOW_KEYBOARD_INPUT ) ;
2613
+ } else if ( documentElement . mozRequestFullScreen ) {
2614
+ documentElement . mozRequestFullScreen ( ) ;
2615
+ } else if ( documentElement . msRequestFullscreen ) {
2616
+ documentElement . msRequestFullscreen ( ) ;
2610
2617
}
2611
2618
}
2612
2619
} ,
2613
2620
exitFullscreen : function exitFullscreen ( ) {
2614
- if ( this . fulled ) {
2615
- var document = this . element . ownerDocument ;
2621
+ var document = this . element . ownerDocument ;
2616
2622
2623
+ if ( this . fulled && ( document . fullscreenElement || document . webkitFullscreenElement || document . mozFullScreenElement || document . msFullscreenElement ) ) {
2624
+ // Document.exitFullscreen()
2617
2625
if ( document . exitFullscreen ) {
2618
2626
document . exitFullscreen ( ) ;
2619
- } else if ( document . msExitFullscreen ) {
2620
- document . msExitFullscreen ( ) ;
2621
- } else if ( document . mozCancelFullScreen ) {
2622
- document . mozCancelFullScreen ( ) ;
2623
2627
} else if ( document . webkitExitFullscreen ) {
2624
2628
document . webkitExitFullscreen ( ) ;
2629
+ } else if ( document . mozCancelFullScreen ) {
2630
+ document . mozCancelFullScreen ( ) ;
2631
+ } else if ( document . msExitFullscreen ) {
2632
+ document . msExitFullscreen ( ) ;
2625
2633
}
2626
2634
}
2627
2635
} ,
0 commit comments