From 04d1f87116804c5f9eddba59ef79c75b61b80c5b Mon Sep 17 00:00:00 2001 From: Victor Häggqvist Date: Thu, 14 Jan 2016 23:03:49 +0100 Subject: only slide image out when touching --- src/LightBox.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/LightBox.js') 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) { -- cgit v1.2.3