diff options
author | Victor Häggqvist <[email protected]> | 2016-01-14 23:03:49 +0100 |
---|---|---|
committer | Victor Häggqvist <[email protected]> | 2016-01-14 23:03:49 +0100 |
commit | 04d1f87116804c5f9eddba59ef79c75b61b80c5b (patch) | |
tree | 0757e05ac05d8d91db8c1e840bf1c7f2f6c649cc /src/LightBox.js | |
parent | 4b570dce9af4307eac2fe8d26323066215464ccd (diff) |
only slide image out when touching
Diffstat (limited to 'src/LightBox.js')
-rw-r--r-- | src/LightBox.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/LightBox.js b/src/LightBox.js index e2094c1..8bb2c48 100644 --- a/src/LightBox.js +++ b/src/LightBox.js @@ -86,7 +86,7 @@ export class LightBox { this.target = this.targets[gotoIndex]; } - this.loadImage(e.keyCode === 37 ? LightDirection.LEFT : LightDirection.RIGHT); + this.loadImage(); } } @@ -169,7 +169,12 @@ export class LightBox { log.debug('unload'); CSSUtil.setTransitionProperty(this.image, 'opacity '+this.options.animationSpeed/1000+'s linear'); - let transitionArgs = (100 * direction) - this.swipeDiff + 'px'; + + let transitionArgs = '0px'; + if (direction !== false) { + transitionArgs = (100 * direction) - this.swipeDiff + 'px'; + } + this.image.style.transform = 'translateX('+transitionArgs+')'; setTimeout(() => { @@ -287,7 +292,7 @@ export class LightBox { this.target = this.targets[gotoIndex]; } - this.loadImage(this.imageWidth / 2 > posX ? LightDirection.LEFT : LightDirection.RIGHT); + this.loadImage(); } imageTouchStart(e) { |