diff --git a/build/zooming.js b/build/zooming.js index 3f8527e6..b4b02ebe 100644 --- a/build/zooming.js +++ b/build/zooming.js @@ -123,35 +123,6 @@ function sniffTransition(el) { return res; } -/** - * A list of options. - * - * @type {Object} - * @example - * // Default options - * const options = { - * defaultZoomable: 'img[data-action="zoom"]', - * enableGrab: true, - * preloadImage: false, - * closeOnWindowResize: true, - * transitionDuration: 0.4, - * transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)', - * bgColor: 'rgb(255, 255, 255)', - * bgOpacity: 1, - * scaleBase: 1.0, - * scaleExtra: 0.5, - * scrollThreshold: 40, - * zIndex: 998, - * customSize: null, - * onOpen: null, - * onClose: null, - * onRelease: null, - * onBeforeOpen: null, - * onBeforeClose: null, - * onBeforeGrab: null, - * onBeforeRelease: null - * } - */ var DEFAULT_OPTIONS = { /** * Zoomable elements by default. It can be a css selector or an element. @@ -462,6 +433,10 @@ var overlay = { } }; +// Translate z-axis to fix CSS grid display issue in Chrome: +// https://github.com/kingdido999/zooming/issues/42 +var TRANSLATE_Z = 0; + var target = { init: function init(el, instance) { this.el = el; @@ -485,7 +460,7 @@ var target = { zIndex: options.zIndex + 1, cursor: options.enableGrab ? cursor.grab : cursor.zoomOut, transition: transformCssProp + '\n ' + options.transitionDuration + 's\n ' + options.transitionTimingFunction, - transform: 'translate(' + this.translate.x + 'px, ' + this.translate.y + 'px)\n scale(' + this.scale.x + ',' + this.scale.y + ')', + transform: 'translate3d(' + this.translate.x + 'px, ' + this.translate.y + 'px, ' + TRANSLATE_Z + 'px)\n scale(' + this.scale.x + ',' + this.scale.y + ')', height: this.rect.height + 'px', width: this.rect.width + 'px' @@ -509,7 +484,7 @@ var target = { setStyle(this.el, { cursor: cursor.move, - transform: 'translate(\n ' + (this.translate.x + dx) + 'px, ' + (this.translate.y + dy) + 'px)\n scale(' + (this.scale.x + scaleExtra) + ',' + (this.scale.y + scaleExtra) + ')' + transform: 'translate3d(\n ' + (this.translate.x + dx) + 'px, ' + (this.translate.y + dy) + 'px, ' + TRANSLATE_Z + 'px)\n scale(' + (this.scale.x + scaleExtra) + ',' + (this.scale.y + scaleExtra) + ')' }); }, move: function move(x, y, scaleExtra) { @@ -520,7 +495,7 @@ var target = { setStyle(this.el, { transition: transformCssProp, - transform: 'translate(\n ' + (this.translate.x + dx) + 'px, ' + (this.translate.y + dy) + 'px)\n scale(' + (this.scale.x + scaleExtra) + ',' + (this.scale.y + scaleExtra) + ')' + transform: 'translate3d(\n ' + (this.translate.x + dx) + 'px, ' + (this.translate.y + dy) + 'px, ' + TRANSLATE_Z + 'px)\n scale(' + (this.scale.x + scaleExtra) + ',' + (this.scale.y + scaleExtra) + ')' }); }, restoreCloseStyle: function restoreCloseStyle() { @@ -654,10 +629,6 @@ var _extends = Object.assign || function (target) { return target; }; -/** - * Zooming instance. - */ - var Zooming$1 = function () { /** * @param {Object} [options] Update default options if provided. diff --git a/build/zooming.js.map b/build/zooming.js.map index 56c2417f..2ccbf7ac 100644 --- a/build/zooming.js.map +++ b/build/zooming.js.map @@ -1 +1 @@ -{"version":3,"file":"zooming.js","sources":["../src/utils.js","../src/options.js","../src/modules/handler.js","../src/modules/overlay.js","../src/modules/target.js","../src/modules/zooming.js","../src/index.js"],"sourcesContent":["export const webkitPrefix = 'WebkitAppearance' in document.documentElement.style\n ? '-webkit-'\n : ''\n\nexport const cursor = {\n default: 'auto',\n zoomIn: `${webkitPrefix}zoom-in`,\n zoomOut: `${webkitPrefix}zoom-out`,\n grab: `${webkitPrefix}grab`,\n move: 'move'\n}\n\nexport function listen(el, event, handler, add = true) {\n const options = { passive: false }\n\n if (add) {\n el.addEventListener(event, handler, options)\n } else {\n el.removeEventListener(event, handler, options)\n }\n}\n\nexport function loadImage(src, cb) {\n if (src) {\n const img = new Image()\n\n img.onload = function onImageLoad() {\n if (cb) cb(img)\n }\n\n img.src = src\n }\n}\n\nexport function getOriginalSource(el) {\n if (el.hasAttribute('data-original')) {\n return el.getAttribute('data-original')\n } else if (el.parentNode.tagName === 'A') {\n return el.parentNode.getAttribute('href')\n } else {\n return null\n }\n}\n\nexport function setStyle(el, styles, remember) {\n checkTrans(styles)\n\n let s = el.style\n let original = {}\n\n for (let key in styles) {\n if (remember) {\n original[key] = s[key] || ''\n }\n\n s[key] = styles[key]\n }\n\n return original\n}\n\nexport function bindAll(_this, that) {\n const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(_this))\n methods.forEach(function bindOne(method) {\n _this[method] = _this[method].bind(that)\n })\n}\n\nconst trans = sniffTransition(document.createElement('div'))\nexport const transformCssProp = trans.transformCssProp\nexport const transEndEvent = trans.transEndEvent\n\nfunction checkTrans(styles) {\n const { transitionProp, transformProp } = trans\n\n if (styles.transition) {\n const value = styles.transition\n delete styles.transition\n styles[transitionProp] = value\n }\n\n if (styles.transform) {\n const value = styles.transform\n delete styles.transform\n styles[transformProp] = value\n }\n}\n\nfunction sniffTransition(el) {\n let res = {}\n const trans = ['webkitTransition', 'transition', 'mozTransition']\n const tform = ['webkitTransform', 'transform', 'mozTransform']\n const end = {\n transition: 'transitionend',\n mozTransition: 'transitionend',\n webkitTransition: 'webkitTransitionEnd'\n }\n\n trans.some(function hasTransition(prop) {\n if (el.style[prop] !== undefined) {\n res.transitionProp = prop\n res.transEndEvent = end[prop]\n return true\n }\n })\n\n tform.some(function hasTransform(prop) {\n if (el.style[prop] !== undefined) {\n res.transformProp = prop\n res.transformCssProp = prop.replace(/(.*)Transform/, '-$1-transform')\n return true\n }\n })\n\n return res\n}\n","/**\n * A list of options.\n *\n * @type {Object}\n * @example\n * // Default options\n * const options = {\n * defaultZoomable: 'img[data-action=\"zoom\"]',\n * enableGrab: true,\n * preloadImage: false,\n * closeOnWindowResize: true,\n * transitionDuration: 0.4,\n * transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)',\n * bgColor: 'rgb(255, 255, 255)',\n * bgOpacity: 1,\n * scaleBase: 1.0,\n * scaleExtra: 0.5,\n * scrollThreshold: 40,\n * zIndex: 998,\n * customSize: null,\n * onOpen: null,\n * onClose: null,\n * onRelease: null,\n * onBeforeOpen: null,\n * onBeforeClose: null,\n * onBeforeGrab: null,\n * onBeforeRelease: null\n * }\n */\nexport default {\n /**\n * Zoomable elements by default. It can be a css selector or an element.\n * @type {string|Element}\n */\n defaultZoomable: 'img[data-action=\"zoom\"]',\n\n /**\n * To be able to grab and drag the image for extra zoom-in.\n * @type {boolean}\n */\n enableGrab: true,\n\n /**\n * Preload zoomable images.\n * @type {boolean}\n */\n preloadImage: false,\n\n /**\n * Close the zoomed image when browser window is resized.\n * @type {boolean}\n */\n closeOnWindowResize: true,\n\n /**\n * Transition duration in seconds.\n * @type {number}\n */\n transitionDuration: 0.4,\n\n /**\n * Transition timing function.\n * @type {string}\n */\n transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)',\n\n /**\n * Overlay background color.\n * @type {string}\n */\n bgColor: 'rgb(255, 255, 255)',\n\n /**\n * Overlay background opacity.\n * @type {number}\n */\n bgOpacity: 1,\n\n /**\n * The base scale factor for zooming. By default scale to fit the window.\n * @type {number}\n */\n scaleBase: 1.0,\n\n /**\n * The additional scale factor when grabbing the image.\n * @type {number}\n */\n scaleExtra: 0.5,\n\n /**\n * How much scrolling it takes before closing out.\n * @type {number}\n */\n scrollThreshold: 40,\n\n /**\n * The z-index that the overlay will be added with.\n * @type {number}\n */\n zIndex: 998,\n\n /**\n * Scale (zoom in) to given width and height. Ignore scaleBase if set.\n * @type {Object}\n * @example\n * customSize: { width: 800, height: 400 }\n */\n customSize: null,\n\n /**\n * A callback function that will be called when a target is opened and\n * transition has ended. It will get the target element as the argument.\n * @type {Function}\n */\n onOpen: null,\n\n /**\n * Same as above, except fired when closed.\n * @type {Function}\n */\n onClose: null,\n\n /**\n * Same as above, except fired when grabbed.\n * @type {Function}\n */\n onGrab: null,\n\n /**\n * Same as above, except fired when moved.\n * @type {Function}\n */\n onMove: null,\n\n /**\n * Same as above, except fired when released.\n * @type {Function}\n */\n onRelease: null,\n\n /**\n * A callback function that will be called before open.\n * @type {Function}\n */\n onBeforeOpen: null,\n\n /**\n * A callback function that will be called before close.\n * @type {Function}\n */\n onBeforeClose: null,\n\n /**\n * A callback function that will be called before grab.\n * @type {Function}\n */\n onBeforeGrab: null,\n\n /**\n * A callback function that will be called before release.\n * @type {Function}\n */\n onBeforeRelease: null\n}\n","import { bindAll } from '../utils'\n\nconst PRESS_DELAY = 200\n\nexport default {\n init(instance) {\n bindAll(this, instance)\n },\n\n click(e) {\n e.preventDefault()\n\n if (isPressingMetaKey(e)) {\n return window.open(\n this.target.srcOriginal || e.currentTarget.src,\n '_blank'\n )\n } else {\n if (this.shown) {\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n } else {\n this.open(e.currentTarget)\n }\n }\n },\n\n scroll() {\n const el =\n document.documentElement || document.body.parentNode || document.body\n const scrollLeft = window.pageXOffset || el.scrollLeft\n const scrollTop = window.pageYOffset || el.scrollTop\n\n if (this.lastScrollPosition === null) {\n this.lastScrollPosition = {\n x: scrollLeft,\n y: scrollTop\n }\n }\n\n const deltaX = this.lastScrollPosition.x - scrollLeft\n const deltaY = this.lastScrollPosition.y - scrollTop\n const threshold = this.options.scrollThreshold\n\n if (Math.abs(deltaY) >= threshold || Math.abs(deltaX) >= threshold) {\n this.lastScrollPosition = null\n this.close()\n }\n },\n\n keydown(e) {\n if (isEscape(e)) {\n if (this.released) {\n this.close()\n } else {\n this.release(this.close)\n }\n }\n },\n\n mousedown(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n e.preventDefault()\n const { clientX, clientY } = e\n\n this.pressTimer = setTimeout(\n function grabOnMouseDown() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n mousemove(e) {\n if (this.released) return\n this.move(e.clientX, e.clientY)\n },\n\n mouseup(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n touchstart(e) {\n e.preventDefault()\n const { clientX, clientY } = e.touches[0]\n\n this.pressTimer = setTimeout(\n function grabOnTouchStart() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n touchmove(e) {\n if (this.released) return\n\n const { clientX, clientY } = e.touches[0]\n this.move(clientX, clientY)\n },\n\n touchend(e) {\n if (isTouching(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n clickOverlay() {\n this.close()\n },\n\n resizeWindow() {\n this.close()\n }\n}\n\nfunction isLeftButton(e) {\n return e.button === 0\n}\n\nfunction isPressingMetaKey(e) {\n return e.metaKey || e.ctrlKey\n}\n\nfunction isTouching(e) {\n e.targetTouches.length > 0\n}\n\nfunction isEscape(e) {\n const code = e.key || e.code\n return code === 'Escape' || e.keyCode === 27\n}\n","import { listen, setStyle } from '../utils'\n\nexport default {\n init(instance) {\n this.el = document.createElement('div')\n this.instance = instance\n this.parent = document.body\n\n setStyle(this.el, {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: 0\n })\n\n this.updateStyle(instance.options)\n listen(this.el, 'click', instance.handler.clickOverlay.bind(instance))\n },\n\n updateStyle(options) {\n setStyle(this.el, {\n zIndex: options.zIndex,\n backgroundColor: options.bgColor,\n transition: `opacity\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`\n })\n },\n\n insert() {\n this.parent.appendChild(this.el)\n },\n\n remove() {\n this.parent.removeChild(this.el)\n },\n\n fadeIn() {\n this.el.offsetWidth\n this.el.style.opacity = this.instance.options.bgOpacity\n },\n\n fadeOut() {\n this.el.style.opacity = 0\n }\n}\n","import { cursor, setStyle, getOriginalSource, transformCssProp } from '../utils'\n\nexport default {\n init(el, instance) {\n this.el = el\n this.instance = instance\n this.srcThumbnail = this.el.getAttribute('src')\n this.srcOriginal = getOriginalSource(this.el)\n this.rect = el.getBoundingClientRect()\n this.translate = null\n this.scale = null\n this.styleOpen = null\n this.styleClose = null\n },\n\n zoomIn() {\n const options = this.instance.options\n\n this.translate = calculateTranslate(this.rect)\n this.scale = calculateScale(\n this.rect,\n options.scaleBase,\n options.customSize\n )\n\n this.styleOpen = {\n position: 'relative',\n zIndex: options.zIndex + 1,\n cursor: options.enableGrab ? cursor.grab : cursor.zoomOut,\n transition: `${transformCssProp}\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`,\n transform: `translate(${this.translate.x}px, ${this.translate.y}px)\n scale(${this.scale.x},${this.scale.y})`,\n height: `${this.rect.height}px`,\n width: `${this.rect.width}px`\n }\n\n // Force layout update\n this.el.offsetWidth\n\n // Trigger transition\n this.styleClose = setStyle(this.el, this.styleOpen, true)\n },\n\n zoomOut() {\n // Force layout update\n this.el.offsetWidth\n\n setStyle(this.el, { transform: 'none' })\n },\n\n grab(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n cursor: cursor.move,\n transform: `translate(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n move(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n transition: transformCssProp,\n transform: `translate(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n restoreCloseStyle() {\n setStyle(this.el, this.styleClose)\n },\n\n restoreOpenStyle() {\n setStyle(this.el, this.styleOpen)\n },\n\n upgradeSource() {\n if (this.srcOriginal) {\n const parentNode = this.el.parentNode\n const temp = this.el.cloneNode(false)\n\n // Force compute the hi-res image in DOM to prevent\n // image flickering while updating src\n temp.setAttribute('src', this.srcOriginal)\n temp.style.position = 'fixed'\n temp.style.visibility = 'hidden'\n parentNode.appendChild(temp)\n\n // Add delay to prevent Firefox from flickering\n setTimeout(\n function updateSrc() {\n this.el.setAttribute('src', this.srcOriginal)\n parentNode.removeChild(temp)\n }.bind(this),\n 50\n )\n }\n },\n\n downgradeSource() {\n if (this.srcOriginal) {\n this.el.setAttribute('src', this.srcThumbnail)\n }\n }\n}\n\nfunction calculateTranslate(rect) {\n const windowCenter = getWindowCenter()\n const targetCenter = {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2\n }\n\n // The vector to translate image to the window center\n return {\n x: windowCenter.x - targetCenter.x,\n y: windowCenter.y - targetCenter.y\n }\n}\n\nfunction calculateScale(rect, scaleBase, customSize) {\n if (customSize) {\n return {\n x: customSize.width / rect.width,\n y: customSize.height / rect.height\n }\n } else {\n const targetHalfWidth = rect.width / 2\n const targetHalfHeight = rect.height / 2\n const windowCenter = getWindowCenter()\n\n // The distance between target edge and window edge\n const targetEdgeToWindowEdge = {\n x: windowCenter.x - targetHalfWidth,\n y: windowCenter.y - targetHalfHeight\n }\n\n const scaleHorizontally = targetEdgeToWindowEdge.x / targetHalfWidth\n const scaleVertically = targetEdgeToWindowEdge.y / targetHalfHeight\n\n // The additional scale is based on the smaller value of\n // scaling horizontally and scaling vertically\n const scale = scaleBase + Math.min(scaleHorizontally, scaleVertically)\n\n return {\n x: scale,\n y: scale\n }\n }\n}\n\nfunction getWindowCenter() {\n const docEl = document.documentElement\n const windowWidth = Math.min(docEl.clientWidth, window.innerWidth)\n const windowHeight = Math.min(docEl.clientHeight, window.innerHeight)\n\n return {\n x: windowWidth / 2,\n y: windowHeight / 2\n }\n}\n","import {\n cursor,\n listen,\n loadImage,\n transEndEvent,\n getOriginalSource\n} from '../utils'\nimport DEFAULT_OPTIONS from '../options'\n\nimport handler from './handler'\nimport overlay from './overlay'\nimport target from './target'\n\n/**\n * Zooming instance.\n */\nexport default class Zooming {\n /**\n * @param {Object} [options] Update default options if provided.\n */\n constructor(options) {\n this.target = Object.create(target)\n this.overlay = Object.create(overlay)\n this.handler = Object.create(handler)\n this.body = document.body\n\n this.shown = false\n this.lock = false\n this.released = true\n this.lastScrollPosition = null\n this.pressTimer = null\n\n this.options = Object.assign({}, DEFAULT_OPTIONS, options)\n this.overlay.init(this)\n this.handler.init(this)\n this.listen(this.options.defaultZoomable)\n }\n\n /**\n * Make element(s) zoomable.\n * @param {string|Element} el A css selector or an Element.\n * @return {this}\n */\n listen(el) {\n if (typeof el === 'string') {\n const els = document.querySelectorAll(el)\n let i = els.length\n\n while (i--) {\n this.listen(els[i])\n }\n } else if (el.tagName === 'IMG') {\n el.style.cursor = cursor.zoomIn\n listen(el, 'click', this.handler.click)\n\n if (this.options.preloadImage) {\n loadImage(getOriginalSource(el))\n }\n }\n\n return this\n }\n\n /**\n * Update options or return current options if no argument is provided.\n * @param {Object} options An Object that contains this.options.\n * @return {this|this.options}\n */\n config(options) {\n if (options) {\n Object.assign(this.options, options)\n this.overlay.updateStyle(this.options)\n return this\n } else {\n return this.options\n }\n }\n\n /**\n * Open (zoom in) the Element.\n * @param {Element} el The Element to open.\n * @param {Function} [cb=this.options.onOpen] A callback function that will\n * be called when a target is opened and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n open(el, cb = this.options.onOpen) {\n if (this.shown || this.lock) return\n\n const target = typeof el === 'string' ? document.querySelector(el) : el\n\n if (target.tagName !== 'IMG') return\n\n if (this.options.onBeforeOpen) {\n this.options.onBeforeOpen(target)\n }\n\n this.target.init(target, this)\n\n if (!this.options.preloadImage) {\n loadImage(this.target.srcOriginal)\n }\n\n this.shown = true\n this.lock = true\n\n this.target.zoomIn()\n this.overlay.insert()\n this.overlay.fadeIn()\n\n listen(document, 'scroll', this.handler.scroll)\n listen(document, 'keydown', this.handler.keydown)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow)\n }\n\n const onOpenEnd = () => {\n listen(target, transEndEvent, onOpenEnd, false)\n this.lock = false\n this.target.upgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, true)\n }\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onOpenEnd)\n\n return this\n }\n\n /**\n * Close (zoom out) the Element currently opened.\n * @param {Function} [cb=this.options.onClose] A callback function that will\n * be called when a target is closed and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n close(cb = this.options.onClose) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeClose) {\n this.options.onBeforeClose(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.overlay.fadeOut()\n this.target.zoomOut()\n\n listen(document, 'scroll', this.handler.scroll, false)\n listen(document, 'keydown', this.handler.keydown, false)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow, false)\n }\n\n const onCloseEnd = () => {\n listen(target, transEndEvent, onCloseEnd, false)\n\n this.shown = false\n this.lock = false\n\n this.target.downgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, false)\n }\n\n this.target.restoreCloseStyle()\n this.overlay.remove()\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onCloseEnd)\n\n return this\n }\n\n /**\n * Grab the Element currently opened given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onGrab] A callback function that\n * will be called when a target is grabbed and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n grab(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onGrab) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeGrab) {\n this.options.onBeforeGrab(target)\n }\n\n this.released = false\n this.target.grab(x, y, scaleExtra)\n\n const onGrabEnd = () => {\n listen(target, transEndEvent, onGrabEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onGrabEnd)\n\n return this\n }\n\n /**\n * Move the Element currently grabbed given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onMove] A callback function that\n * will be called when a target is moved and transition has ended. It will\n * get the target element as the argument.\n * @return {this}\n */\n move(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onMove) {\n if (!this.shown || this.lock) return\n\n this.released = false\n this.body.style.cursor = cursor.move\n this.target.move(x, y, scaleExtra)\n\n const target = this.target.el\n\n const onMoveEnd = () => {\n listen(target, transEndEvent, onMoveEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onMoveEnd)\n\n return this\n }\n\n /**\n * Release the Element currently grabbed.\n * @param {Function} [cb=this.options.onRelease] A callback function that\n * will be called when a target is released and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n release(cb = this.options.onRelease) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeRelease) {\n this.options.onBeforeRelease(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.target.restoreOpenStyle()\n\n const onReleaseEnd = () => {\n listen(target, transEndEvent, onReleaseEnd, false)\n this.lock = false\n this.released = true\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onReleaseEnd)\n\n return this\n }\n}\n\nfunction toggleGrabListeners(el, handler, add) {\n const types = [\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'touchstart',\n 'touchmove',\n 'touchend'\n ]\n\n types.forEach(function toggleListener(type) {\n listen(el, type, handler[type], add)\n })\n}\n","import { listen } from './utils'\nimport Zooming from './modules/zooming'\n\nlisten(document, 'DOMContentLoaded', function initZooming() {\n new Zooming()\n})\n\nexport default Zooming\n"],"names":["webkitPrefix","document","documentElement","style","cursor","listen","el","event","handler","add","options","passive","addEventListener","removeEventListener","loadImage","src","cb","img","Image","onload","onImageLoad","getOriginalSource","hasAttribute","getAttribute","parentNode","tagName","setStyle","styles","remember","s","original","key","bindAll","_this","that","methods","Object","getOwnPropertyNames","getPrototypeOf","forEach","bindOne","method","bind","trans","sniffTransition","createElement","transformCssProp","transEndEvent","checkTrans","transitionProp","transformProp","transition","value","transform","res","tform","end","some","hasTransition","prop","undefined","hasTransform","replace","PRESS_DELAY","instance","e","preventDefault","isPressingMetaKey","window","open","target","srcOriginal","currentTarget","shown","released","close","release","body","scrollLeft","pageXOffset","scrollTop","pageYOffset","lastScrollPosition","deltaX","x","deltaY","y","threshold","scrollThreshold","Math","abs","isEscape","isLeftButton","clientX","clientY","pressTimer","setTimeout","grabOnMouseDown","grab","move","touches","grabOnTouchStart","isTouching","button","metaKey","ctrlKey","targetTouches","length","code","keyCode","parent","updateStyle","clickOverlay","zIndex","bgColor","transitionDuration","transitionTimingFunction","appendChild","removeChild","offsetWidth","opacity","bgOpacity","srcThumbnail","rect","getBoundingClientRect","translate","scale","styleOpen","styleClose","calculateTranslate","calculateScale","scaleBase","customSize","enableGrab","zoomOut","height","width","scaleExtra","windowCenter","getWindowCenter","dx","dy","temp","cloneNode","setAttribute","position","visibility","updateSrc","targetCenter","left","top","targetHalfWidth","targetHalfHeight","targetEdgeToWindowEdge","scaleHorizontally","scaleVertically","min","docEl","windowWidth","clientWidth","innerWidth","windowHeight","clientHeight","innerHeight","Zooming","create","overlay","lock","babelHelpers.extends","DEFAULT_OPTIONS","init","defaultZoomable","els","querySelectorAll","i","zoomIn","click","preloadImage","onOpen","querySelector","onBeforeOpen","insert","fadeIn","scroll","keydown","closeOnWindowResize","resizeWindow","onOpenEnd","upgradeSource","onClose","onBeforeClose","default","fadeOut","onCloseEnd","downgradeSource","restoreCloseStyle","remove","onGrab","onBeforeGrab","onGrabEnd","onMove","onMoveEnd","onRelease","onBeforeRelease","restoreOpenStyle","onReleaseEnd","toggleGrabListeners","types","toggleListener","type","initZooming"],"mappings":";;;;;;AAAO,IAAMA,eAAe,sBAAsBC,SAASC,eAAT,CAAyBC,KAA/C,GACxB,UADwB,GAExB,EAFG;;AAIP,AAAO,IAAMC,SAAS;WACX,MADW;UAETJ,YAAX,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C,SAAJ;CADF,EAIA;;;;"} \ No newline at end of file +{"version":3,"file":"zooming.js","sources":["../src/utils.js","../src/options.js","../src/modules/handler.js","../src/modules/overlay.js","../src/modules/target.js","../src/modules/zooming.js","../src/index.js"],"sourcesContent":["export const webkitPrefix = 'WebkitAppearance' in document.documentElement.style\n ? '-webkit-'\n : ''\n\nexport const cursor = {\n default: 'auto',\n zoomIn: `${webkitPrefix}zoom-in`,\n zoomOut: `${webkitPrefix}zoom-out`,\n grab: `${webkitPrefix}grab`,\n move: 'move'\n}\n\nexport function listen(el, event, handler, add = true) {\n const options = { passive: false }\n\n if (add) {\n el.addEventListener(event, handler, options)\n } else {\n el.removeEventListener(event, handler, options)\n }\n}\n\nexport function loadImage(src, cb) {\n if (src) {\n const img = new Image()\n\n img.onload = function onImageLoad() {\n if (cb) cb(img)\n }\n\n img.src = src\n }\n}\n\nexport function getOriginalSource(el) {\n if (el.hasAttribute('data-original')) {\n return el.getAttribute('data-original')\n } else if (el.parentNode.tagName === 'A') {\n return el.parentNode.getAttribute('href')\n } else {\n return null\n }\n}\n\nexport function setStyle(el, styles, remember) {\n checkTrans(styles)\n\n let s = el.style\n let original = {}\n\n for (let key in styles) {\n if (remember) {\n original[key] = s[key] || ''\n }\n\n s[key] = styles[key]\n }\n\n return original\n}\n\nexport function bindAll(_this, that) {\n const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(_this))\n methods.forEach(function bindOne(method) {\n _this[method] = _this[method].bind(that)\n })\n}\n\nconst trans = sniffTransition(document.createElement('div'))\nexport const transformCssProp = trans.transformCssProp\nexport const transEndEvent = trans.transEndEvent\n\nfunction checkTrans(styles) {\n const { transitionProp, transformProp } = trans\n\n if (styles.transition) {\n const value = styles.transition\n delete styles.transition\n styles[transitionProp] = value\n }\n\n if (styles.transform) {\n const value = styles.transform\n delete styles.transform\n styles[transformProp] = value\n }\n}\n\nfunction sniffTransition(el) {\n let res = {}\n const trans = ['webkitTransition', 'transition', 'mozTransition']\n const tform = ['webkitTransform', 'transform', 'mozTransform']\n const end = {\n transition: 'transitionend',\n mozTransition: 'transitionend',\n webkitTransition: 'webkitTransitionEnd'\n }\n\n trans.some(function hasTransition(prop) {\n if (el.style[prop] !== undefined) {\n res.transitionProp = prop\n res.transEndEvent = end[prop]\n return true\n }\n })\n\n tform.some(function hasTransform(prop) {\n if (el.style[prop] !== undefined) {\n res.transformProp = prop\n res.transformCssProp = prop.replace(/(.*)Transform/, '-$1-transform')\n return true\n }\n })\n\n return res\n}\n","export default {\n /**\n * Zoomable elements by default. It can be a css selector or an element.\n * @type {string|Element}\n */\n defaultZoomable: 'img[data-action=\"zoom\"]',\n\n /**\n * To be able to grab and drag the image for extra zoom-in.\n * @type {boolean}\n */\n enableGrab: true,\n\n /**\n * Preload zoomable images.\n * @type {boolean}\n */\n preloadImage: false,\n\n /**\n * Close the zoomed image when browser window is resized.\n * @type {boolean}\n */\n closeOnWindowResize: true,\n\n /**\n * Transition duration in seconds.\n * @type {number}\n */\n transitionDuration: 0.4,\n\n /**\n * Transition timing function.\n * @type {string}\n */\n transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)',\n\n /**\n * Overlay background color.\n * @type {string}\n */\n bgColor: 'rgb(255, 255, 255)',\n\n /**\n * Overlay background opacity.\n * @type {number}\n */\n bgOpacity: 1,\n\n /**\n * The base scale factor for zooming. By default scale to fit the window.\n * @type {number}\n */\n scaleBase: 1.0,\n\n /**\n * The additional scale factor when grabbing the image.\n * @type {number}\n */\n scaleExtra: 0.5,\n\n /**\n * How much scrolling it takes before closing out.\n * @type {number}\n */\n scrollThreshold: 40,\n\n /**\n * The z-index that the overlay will be added with.\n * @type {number}\n */\n zIndex: 998,\n\n /**\n * Scale (zoom in) to given width and height. Ignore scaleBase if set.\n * @type {Object}\n * @example\n * customSize: { width: 800, height: 400 }\n */\n customSize: null,\n\n /**\n * A callback function that will be called when a target is opened and\n * transition has ended. It will get the target element as the argument.\n * @type {Function}\n */\n onOpen: null,\n\n /**\n * Same as above, except fired when closed.\n * @type {Function}\n */\n onClose: null,\n\n /**\n * Same as above, except fired when grabbed.\n * @type {Function}\n */\n onGrab: null,\n\n /**\n * Same as above, except fired when moved.\n * @type {Function}\n */\n onMove: null,\n\n /**\n * Same as above, except fired when released.\n * @type {Function}\n */\n onRelease: null,\n\n /**\n * A callback function that will be called before open.\n * @type {Function}\n */\n onBeforeOpen: null,\n\n /**\n * A callback function that will be called before close.\n * @type {Function}\n */\n onBeforeClose: null,\n\n /**\n * A callback function that will be called before grab.\n * @type {Function}\n */\n onBeforeGrab: null,\n\n /**\n * A callback function that will be called before release.\n * @type {Function}\n */\n onBeforeRelease: null\n}\n","import { bindAll } from '../utils'\n\nconst PRESS_DELAY = 200\n\nexport default {\n init(instance) {\n bindAll(this, instance)\n },\n\n click(e) {\n e.preventDefault()\n\n if (isPressingMetaKey(e)) {\n return window.open(\n this.target.srcOriginal || e.currentTarget.src,\n '_blank'\n )\n } else {\n if (this.shown) {\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n } else {\n this.open(e.currentTarget)\n }\n }\n },\n\n scroll() {\n const el =\n document.documentElement || document.body.parentNode || document.body\n const scrollLeft = window.pageXOffset || el.scrollLeft\n const scrollTop = window.pageYOffset || el.scrollTop\n\n if (this.lastScrollPosition === null) {\n this.lastScrollPosition = {\n x: scrollLeft,\n y: scrollTop\n }\n }\n\n const deltaX = this.lastScrollPosition.x - scrollLeft\n const deltaY = this.lastScrollPosition.y - scrollTop\n const threshold = this.options.scrollThreshold\n\n if (Math.abs(deltaY) >= threshold || Math.abs(deltaX) >= threshold) {\n this.lastScrollPosition = null\n this.close()\n }\n },\n\n keydown(e) {\n if (isEscape(e)) {\n if (this.released) {\n this.close()\n } else {\n this.release(this.close)\n }\n }\n },\n\n mousedown(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n e.preventDefault()\n const { clientX, clientY } = e\n\n this.pressTimer = setTimeout(\n function grabOnMouseDown() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n mousemove(e) {\n if (this.released) return\n this.move(e.clientX, e.clientY)\n },\n\n mouseup(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n touchstart(e) {\n e.preventDefault()\n const { clientX, clientY } = e.touches[0]\n\n this.pressTimer = setTimeout(\n function grabOnTouchStart() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n touchmove(e) {\n if (this.released) return\n\n const { clientX, clientY } = e.touches[0]\n this.move(clientX, clientY)\n },\n\n touchend(e) {\n if (isTouching(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n clickOverlay() {\n this.close()\n },\n\n resizeWindow() {\n this.close()\n }\n}\n\nfunction isLeftButton(e) {\n return e.button === 0\n}\n\nfunction isPressingMetaKey(e) {\n return e.metaKey || e.ctrlKey\n}\n\nfunction isTouching(e) {\n e.targetTouches.length > 0\n}\n\nfunction isEscape(e) {\n const code = e.key || e.code\n return code === 'Escape' || e.keyCode === 27\n}\n","import { listen, setStyle } from '../utils'\n\nexport default {\n init(instance) {\n this.el = document.createElement('div')\n this.instance = instance\n this.parent = document.body\n\n setStyle(this.el, {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: 0\n })\n\n this.updateStyle(instance.options)\n listen(this.el, 'click', instance.handler.clickOverlay.bind(instance))\n },\n\n updateStyle(options) {\n setStyle(this.el, {\n zIndex: options.zIndex,\n backgroundColor: options.bgColor,\n transition: `opacity\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`\n })\n },\n\n insert() {\n this.parent.appendChild(this.el)\n },\n\n remove() {\n this.parent.removeChild(this.el)\n },\n\n fadeIn() {\n this.el.offsetWidth\n this.el.style.opacity = this.instance.options.bgOpacity\n },\n\n fadeOut() {\n this.el.style.opacity = 0\n }\n}\n","import { cursor, setStyle, getOriginalSource, transformCssProp } from '../utils'\n\n// Translate z-axis to fix CSS grid display issue in Chrome:\n// https://github.com/kingdido999/zooming/issues/42 \nconst TRANSLATE_Z = 0\n\nexport default {\n init(el, instance) {\n this.el = el\n this.instance = instance\n this.srcThumbnail = this.el.getAttribute('src')\n this.srcOriginal = getOriginalSource(this.el)\n this.rect = el.getBoundingClientRect()\n this.translate = null\n this.scale = null\n this.styleOpen = null\n this.styleClose = null\n },\n\n zoomIn() {\n const options = this.instance.options\n\n this.translate = calculateTranslate(this.rect)\n this.scale = calculateScale(\n this.rect,\n options.scaleBase,\n options.customSize\n )\n\n this.styleOpen = {\n position: 'relative',\n zIndex: options.zIndex + 1,\n cursor: options.enableGrab ? cursor.grab : cursor.zoomOut,\n transition: `${transformCssProp}\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`,\n transform: `translate3d(${this.translate.x}px, ${this.translate.y}px, ${TRANSLATE_Z}px)\n scale(${this.scale.x},${this.scale.y})`,\n height: `${this.rect.height}px`,\n width: `${this.rect.width}px`\n }\n\n // Force layout update\n this.el.offsetWidth\n\n // Trigger transition\n this.styleClose = setStyle(this.el, this.styleOpen, true)\n },\n\n zoomOut() {\n // Force layout update\n this.el.offsetWidth\n\n setStyle(this.el, { transform: 'none' })\n },\n\n grab(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n cursor: cursor.move,\n transform: `translate3d(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px, ${TRANSLATE_Z}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n move(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n transition: transformCssProp,\n transform: `translate3d(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px, ${TRANSLATE_Z}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n restoreCloseStyle() {\n setStyle(this.el, this.styleClose)\n },\n\n restoreOpenStyle() {\n setStyle(this.el, this.styleOpen)\n },\n\n upgradeSource() {\n if (this.srcOriginal) {\n const parentNode = this.el.parentNode\n const temp = this.el.cloneNode(false)\n\n // Force compute the hi-res image in DOM to prevent\n // image flickering while updating src\n temp.setAttribute('src', this.srcOriginal)\n temp.style.position = 'fixed'\n temp.style.visibility = 'hidden'\n parentNode.appendChild(temp)\n\n // Add delay to prevent Firefox from flickering\n setTimeout(\n function updateSrc() {\n this.el.setAttribute('src', this.srcOriginal)\n parentNode.removeChild(temp)\n }.bind(this),\n 50\n )\n }\n },\n\n downgradeSource() {\n if (this.srcOriginal) {\n this.el.setAttribute('src', this.srcThumbnail)\n }\n }\n}\n\nfunction calculateTranslate(rect) {\n const windowCenter = getWindowCenter()\n const targetCenter = {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2\n }\n\n // The vector to translate image to the window center\n return {\n x: windowCenter.x - targetCenter.x,\n y: windowCenter.y - targetCenter.y\n }\n}\n\nfunction calculateScale(rect, scaleBase, customSize) {\n if (customSize) {\n return {\n x: customSize.width / rect.width,\n y: customSize.height / rect.height\n }\n } else {\n const targetHalfWidth = rect.width / 2\n const targetHalfHeight = rect.height / 2\n const windowCenter = getWindowCenter()\n\n // The distance between target edge and window edge\n const targetEdgeToWindowEdge = {\n x: windowCenter.x - targetHalfWidth,\n y: windowCenter.y - targetHalfHeight\n }\n\n const scaleHorizontally = targetEdgeToWindowEdge.x / targetHalfWidth\n const scaleVertically = targetEdgeToWindowEdge.y / targetHalfHeight\n\n // The additional scale is based on the smaller value of\n // scaling horizontally and scaling vertically\n const scale = scaleBase + Math.min(scaleHorizontally, scaleVertically)\n\n return {\n x: scale,\n y: scale\n }\n }\n}\n\nfunction getWindowCenter() {\n const docEl = document.documentElement\n const windowWidth = Math.min(docEl.clientWidth, window.innerWidth)\n const windowHeight = Math.min(docEl.clientHeight, window.innerHeight)\n\n return {\n x: windowWidth / 2,\n y: windowHeight / 2\n }\n}\n","import {\n cursor,\n listen,\n loadImage,\n transEndEvent,\n getOriginalSource\n} from '../utils'\nimport DEFAULT_OPTIONS from '../options'\n\nimport handler from './handler'\nimport overlay from './overlay'\nimport target from './target'\n\n/**\n * Zooming instance.\n */\nexport default class Zooming {\n /**\n * @param {Object} [options] Update default options if provided.\n */\n constructor(options) {\n this.target = Object.create(target)\n this.overlay = Object.create(overlay)\n this.handler = Object.create(handler)\n this.body = document.body\n\n this.shown = false\n this.lock = false\n this.released = true\n this.lastScrollPosition = null\n this.pressTimer = null\n\n this.options = Object.assign({}, DEFAULT_OPTIONS, options)\n this.overlay.init(this)\n this.handler.init(this)\n this.listen(this.options.defaultZoomable)\n }\n\n /**\n * Make element(s) zoomable.\n * @param {string|Element} el A css selector or an Element.\n * @return {this}\n */\n listen(el) {\n if (typeof el === 'string') {\n const els = document.querySelectorAll(el)\n let i = els.length\n\n while (i--) {\n this.listen(els[i])\n }\n } else if (el.tagName === 'IMG') {\n el.style.cursor = cursor.zoomIn\n listen(el, 'click', this.handler.click)\n\n if (this.options.preloadImage) {\n loadImage(getOriginalSource(el))\n }\n }\n\n return this\n }\n\n /**\n * Update options or return current options if no argument is provided.\n * @param {Object} options An Object that contains this.options.\n * @return {this|this.options}\n */\n config(options) {\n if (options) {\n Object.assign(this.options, options)\n this.overlay.updateStyle(this.options)\n return this\n } else {\n return this.options\n }\n }\n\n /**\n * Open (zoom in) the Element.\n * @param {Element} el The Element to open.\n * @param {Function} [cb=this.options.onOpen] A callback function that will\n * be called when a target is opened and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n open(el, cb = this.options.onOpen) {\n if (this.shown || this.lock) return\n\n const target = typeof el === 'string' ? document.querySelector(el) : el\n\n if (target.tagName !== 'IMG') return\n\n if (this.options.onBeforeOpen) {\n this.options.onBeforeOpen(target)\n }\n\n this.target.init(target, this)\n\n if (!this.options.preloadImage) {\n loadImage(this.target.srcOriginal)\n }\n\n this.shown = true\n this.lock = true\n\n this.target.zoomIn()\n this.overlay.insert()\n this.overlay.fadeIn()\n\n listen(document, 'scroll', this.handler.scroll)\n listen(document, 'keydown', this.handler.keydown)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow)\n }\n\n const onOpenEnd = () => {\n listen(target, transEndEvent, onOpenEnd, false)\n this.lock = false\n this.target.upgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, true)\n }\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onOpenEnd)\n\n return this\n }\n\n /**\n * Close (zoom out) the Element currently opened.\n * @param {Function} [cb=this.options.onClose] A callback function that will\n * be called when a target is closed and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n close(cb = this.options.onClose) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeClose) {\n this.options.onBeforeClose(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.overlay.fadeOut()\n this.target.zoomOut()\n\n listen(document, 'scroll', this.handler.scroll, false)\n listen(document, 'keydown', this.handler.keydown, false)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow, false)\n }\n\n const onCloseEnd = () => {\n listen(target, transEndEvent, onCloseEnd, false)\n\n this.shown = false\n this.lock = false\n\n this.target.downgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, false)\n }\n\n this.target.restoreCloseStyle()\n this.overlay.remove()\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onCloseEnd)\n\n return this\n }\n\n /**\n * Grab the Element currently opened given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onGrab] A callback function that\n * will be called when a target is grabbed and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n grab(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onGrab) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeGrab) {\n this.options.onBeforeGrab(target)\n }\n\n this.released = false\n this.target.grab(x, y, scaleExtra)\n\n const onGrabEnd = () => {\n listen(target, transEndEvent, onGrabEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onGrabEnd)\n\n return this\n }\n\n /**\n * Move the Element currently grabbed given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onMove] A callback function that\n * will be called when a target is moved and transition has ended. It will\n * get the target element as the argument.\n * @return {this}\n */\n move(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onMove) {\n if (!this.shown || this.lock) return\n\n this.released = false\n this.body.style.cursor = cursor.move\n this.target.move(x, y, scaleExtra)\n\n const target = this.target.el\n\n const onMoveEnd = () => {\n listen(target, transEndEvent, onMoveEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onMoveEnd)\n\n return this\n }\n\n /**\n * Release the Element currently grabbed.\n * @param {Function} [cb=this.options.onRelease] A callback function that\n * will be called when a target is released and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n release(cb = this.options.onRelease) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeRelease) {\n this.options.onBeforeRelease(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.target.restoreOpenStyle()\n\n const onReleaseEnd = () => {\n listen(target, transEndEvent, onReleaseEnd, false)\n this.lock = false\n this.released = true\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onReleaseEnd)\n\n return this\n }\n}\n\nfunction toggleGrabListeners(el, handler, add) {\n const types = [\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'touchstart',\n 'touchmove',\n 'touchend'\n ]\n\n types.forEach(function toggleListener(type) {\n listen(el, type, handler[type], add)\n })\n}\n","import { listen } from './utils'\nimport Zooming from './modules/zooming'\n\nlisten(document, 'DOMContentLoaded', function initZooming() {\n new Zooming()\n})\n\nexport default Zooming\n"],"names":["webkitPrefix","document","documentElement","style","cursor","listen","el","event","handler","add","options","passive","addEventListener","removeEventListener","loadImage","src","cb","img","Image","onload","onImageLoad","getOriginalSource","hasAttribute","getAttribute","parentNode","tagName","setStyle","styles","remember","s","original","key","bindAll","_this","that","methods","Object","getOwnPropertyNames","getPrototypeOf","forEach","bindOne","method","bind","trans","sniffTransition","createElement","transformCssProp","transEndEvent","checkTrans","transitionProp","transformProp","transition","value","transform","res","tform","end","some","hasTransition","prop","undefined","hasTransform","replace","PRESS_DELAY","instance","e","preventDefault","isPressingMetaKey","window","open","target","srcOriginal","currentTarget","shown","released","close","release","body","scrollLeft","pageXOffset","scrollTop","pageYOffset","lastScrollPosition","deltaX","x","deltaY","y","threshold","scrollThreshold","Math","abs","isEscape","isLeftButton","clientX","clientY","pressTimer","setTimeout","grabOnMouseDown","grab","move","touches","grabOnTouchStart","isTouching","button","metaKey","ctrlKey","targetTouches","length","code","keyCode","parent","updateStyle","clickOverlay","zIndex","bgColor","transitionDuration","transitionTimingFunction","appendChild","removeChild","offsetWidth","opacity","bgOpacity","TRANSLATE_Z","srcThumbnail","rect","getBoundingClientRect","translate","scale","styleOpen","styleClose","calculateTranslate","calculateScale","scaleBase","customSize","enableGrab","zoomOut","height","width","scaleExtra","windowCenter","getWindowCenter","dx","dy","temp","cloneNode","setAttribute","position","visibility","updateSrc","targetCenter","left","top","targetHalfWidth","targetHalfHeight","targetEdgeToWindowEdge","scaleHorizontally","scaleVertically","min","docEl","windowWidth","clientWidth","innerWidth","windowHeight","clientHeight","innerHeight","Zooming","create","overlay","lock","babelHelpers.extends","DEFAULT_OPTIONS","init","defaultZoomable","els","querySelectorAll","i","zoomIn","click","preloadImage","onOpen","querySelector","onBeforeOpen","insert","fadeIn","scroll","keydown","closeOnWindowResize","resizeWindow","onOpenEnd","upgradeSource","onClose","onBeforeClose","default","fadeOut","onCloseEnd","downgradeSource","restoreCloseStyle","remove","onGrab","onBeforeGrab","onGrabEnd","onMove","onMoveEnd","onRelease","onBeforeRelease","restoreOpenStyle","onReleaseEnd","toggleGrabListeners","types","toggleListener","type","initZooming"],"mappings":";;;;;;AAAO,IAAMA,eAAe,sBAAsBC,SAASC,eAAT,CAAyBC,KAA/C,GACxB,UADwB,GAExB,EAFG;;AAIP,AAAO,IAAMC,SAAS;WACX,MADW;UAETJ,YAAX,YAFoB;WAGRA,YAAZ,aAHoB;QAIXA,YAAT,SAJoB;QAKd;CALD;;AAQP,AAAO,SAASK,MAAT,CAAgBC,EAAhB,EAAoBC,KAApB,EAA2BC,OAA3B,EAAgD;MAAZC,GAAY,uEAAN,IAAM;;MAC/CC,UAAU,EAAEC,SAAS,KAAX,EAAhB;;MAEIF,GAAJ,EAAS;OACJG,gBAAH,CAAoBL,KAApB,EAA2BC,OAA3B,EAAoCE,OAApC;GADF,MAEO;OACFG,mBAAH,CAAuBN,KAAvB,EAA8BC,OAA9B,EAAuCE,OAAvC;;;;AAIJ,AAAO,SAASI,SAAT,CAAmBC,GAAnB,EAAwBC,EAAxB,EAA4B;MAC7BD,GAAJ,EAAS;QACDE,MAAM,IAAIC,KAAJ,EAAZ;;QAEIC,MAAJ,GAAa,SAASC,WAAT,GAAuB;UAC9BJ,EAAJ,EAAQA,GAAGC,GAAH;KADV;;QAIIF,GAAJ,GAAUA,GAAV;;;;AAIJ,AAAO,SAASM,iBAAT,CAA2Bf,EAA3B,EAA+B;MAChCA,GAAGgB,YAAH,CAAgB,eAAhB,CAAJ,EAAsC;WAC7BhB,GAAGiB,YAAH,CAAgB,eAAhB,CAAP;GADF,MAEO,IAAIjB,GAAGkB,UAAH,CAAcC,OAAd,KAA0B,GAA9B,EAAmC;WACjCnB,GAAGkB,UAAH,CAAcD,YAAd,CAA2B,MAA3B,CAAP;GADK,MAEA;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ASC,mBAAT,CAA6BzM,EAA7B,EAAiCE,UAAjC,EAA0CC,GAA1C,EAA+C;MACvCuM,QAAQ,CACZ,WADY,EAEZ,WAFY,EAGZ,SAHY,EAIZ,YAJY,EAKZ,WALY,EAMZ,UANY,CAAd;;QASMzK,OAAN,CAAc,SAAS0K,cAAT,CAAwBC,IAAxB,EAA8B;WACnC5M,EAAP,EAAW4M,IAAX,EAAiB1M,WAAQ0M,IAAR,CAAjB,EAAgCzM,GAAhC;GADF;;;AC/RFJ,OAAOJ,QAAP,EAAiB,kBAAjB,EAAqC,SAASkN,WAAT,GAAuB;MACtD9C,SAAJ;CADF,EAIA;;;;"} \ No newline at end of file diff --git a/build/zooming.min.js b/build/zooming.min.js index 56d70b4e..01f9597d 100644 --- a/build/zooming.min.js +++ b/build/zooming.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Zooming=e()}(this,function(){"use strict";function t(t,e,i){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o={passive:!1};n?t.addEventListener(e,i,o):t.removeEventListener(e,i,o)}function e(t,e){if(t){var i=new Image;i.onload=function(){e&&e(i)},i.src=t}}function i(t){return t.hasAttribute("data-original")?t.getAttribute("data-original"):"A"===t.parentNode.tagName?t.parentNode.getAttribute("href"):null}function n(t,e,i){s(e);var n=t.style,o={};for(var r in e)i&&(o[r]=n[r]||""),n[r]=e[r];return o}function o(t,e){Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(function(i){t[i]=t[i].bind(e)})}function s(t){var e=y.transitionProp,i=y.transformProp;if(t.transition){var n=t.transition;delete t.transition,t[e]=n}if(t.transform){var o=t.transform;delete t.transform,t[i]=o}}function r(t){return 0===t.button}function l(t){return t.metaKey||t.ctrlKey}function a(t){t.targetTouches.length}function h(t){return"Escape"===(t.key||t.code)||27===t.keyCode}function c(t){var e=d(),i={x:t.left+t.width/2,y:t.top+t.height/2};return{x:e.x-i.x,y:e.y-i.y}}function u(t,e,i){if(i)return{x:i.width/t.width,y:i.height/t.height};var n=t.width/2,o=t.height/2,s=d(),r={x:s.x-n,y:s.y-o},l=r.x/n,a=r.y/o,h=e+Math.min(l,a);return{x:h,y:h}}function d(){var t=document.documentElement;return{x:Math.min(t.clientWidth,window.innerWidth)/2,y:Math.min(t.clientHeight,window.innerHeight)/2}}function f(e,i,n){["mousedown","mousemove","mouseup","touchstart","touchmove","touchend"].forEach(function(o){t(e,o,i[o],n)})}var p="WebkitAppearance"in document.documentElement.style?"-webkit-":"",m={default:"auto",zoomIn:p+"zoom-in",zoomOut:p+"zoom-out",grab:p+"grab",move:"move"},y=function(t){var e={},i=["webkitTransition","transition","mozTransition"],n=["webkitTransform","transform","mozTransform"],o={transition:"transitionend",mozTransition:"transitionend",webkitTransition:"webkitTransitionEnd"};return i.some(function(i){if(void 0!==t.style[i])return e.transitionProp=i,e.transEndEvent=o[i],!0}),n.some(function(i){if(void 0!==t.style[i])return e.transformProp=i,e.transformCssProp=i.replace(/(.*)Transform/,"-$1-transform"),!0}),e}(document.createElement("div")),v=y.transformCssProp,g=y.transEndEvent,b={defaultZoomable:'img[data-action="zoom"]',enableGrab:!0,preloadImage:!1,closeOnWindowResize:!0,transitionDuration:.4,transitionTimingFunction:"cubic-bezier(0.4, 0, 0, 1)",bgColor:"rgb(255, 255, 255)",bgOpacity:1,scaleBase:1,scaleExtra:.5,scrollThreshold:40,zIndex:998,customSize:null,onOpen:null,onClose:null,onGrab:null,onMove:null,onRelease:null,onBeforeOpen:null,onBeforeClose:null,onBeforeGrab:null,onBeforeRelease:null},w={init:function(t){o(this,t)},click:function(t){if(t.preventDefault(),l(t))return window.open(this.target.srcOriginal||t.currentTarget.src,"_blank");this.shown?this.released?this.close():this.release():this.open(t.currentTarget)},scroll:function(){var t=document.documentElement||document.body.parentNode||document.body,e=window.pageXOffset||t.scrollLeft,i=window.pageYOffset||t.scrollTop;null===this.lastScrollPosition&&(this.lastScrollPosition={x:e,y:i});var n=this.lastScrollPosition.x-e,o=this.lastScrollPosition.y-i,s=this.options.scrollThreshold;(Math.abs(o)>=s||Math.abs(n)>=s)&&(this.lastScrollPosition=null,this.close())},keydown:function(t){h(t)&&(this.released?this.close():this.release(this.close))},mousedown:function(t){if(r(t)&&!l(t)){t.preventDefault();var e=t.clientX,i=t.clientY;this.pressTimer=setTimeout(function(){this.grab(e,i)}.bind(this),200)}},mousemove:function(t){this.released||this.move(t.clientX,t.clientY)},mouseup:function(t){r(t)&&!l(t)&&(clearTimeout(this.pressTimer),this.released?this.close():this.release())},touchstart:function(t){t.preventDefault();var e=t.touches[0],i=e.clientX,n=e.clientY;this.pressTimer=setTimeout(function(){this.grab(i,n)}.bind(this),200)},touchmove:function(t){if(!this.released){var e=t.touches[0],i=e.clientX,n=e.clientY;this.move(i,n)}},touchend:function(t){a(t)||(clearTimeout(this.pressTimer),this.released?this.close():this.release())},clickOverlay:function(){this.close()},resizeWindow:function(){this.close()}},O={init:function(e){this.el=document.createElement("div"),this.instance=e,this.parent=document.body,n(this.el,{position:"fixed",top:0,left:0,right:0,bottom:0,opacity:0}),this.updateStyle(e.options),t(this.el,"click",e.handler.clickOverlay.bind(e))},updateStyle:function(t){n(this.el,{zIndex:t.zIndex,backgroundColor:t.bgColor,transition:"opacity\n "+t.transitionDuration+"s\n "+t.transitionTimingFunction})},insert:function(){this.parent.appendChild(this.el)},remove:function(){this.parent.removeChild(this.el)},fadeIn:function(){this.el.offsetWidth,this.el.style.opacity=this.instance.options.bgOpacity},fadeOut:function(){this.el.style.opacity=0}},k={init:function(t,e){this.el=t,this.instance=e,this.srcThumbnail=this.el.getAttribute("src"),this.srcOriginal=i(this.el),this.rect=t.getBoundingClientRect(),this.translate=null,this.scale=null,this.styleOpen=null,this.styleClose=null},zoomIn:function(){var t=this.instance.options;this.translate=c(this.rect),this.scale=u(this.rect,t.scaleBase,t.customSize),this.styleOpen={position:"relative",zIndex:t.zIndex+1,cursor:t.enableGrab?m.grab:m.zoomOut,transition:v+"\n "+t.transitionDuration+"s\n "+t.transitionTimingFunction,transform:"translate("+this.translate.x+"px, "+this.translate.y+"px)\n scale("+this.scale.x+","+this.scale.y+")",height:this.rect.height+"px",width:this.rect.width+"px"},this.el.offsetWidth,this.styleClose=n(this.el,this.styleOpen,!0)},zoomOut:function(){this.el.offsetWidth,n(this.el,{transform:"none"})},grab:function(t,e,i){var o=d(),s=o.x-t,r=o.y-e;n(this.el,{cursor:m.move,transform:"translate(\n "+(this.translate.x+s)+"px, "+(this.translate.y+r)+"px)\n scale("+(this.scale.x+i)+","+(this.scale.y+i)+")"})},move:function(t,e,i){var o=d(),s=o.x-t,r=o.y-e;n(this.el,{transition:v,transform:"translate(\n "+(this.translate.x+s)+"px, "+(this.translate.y+r)+"px)\n scale("+(this.scale.x+i)+","+(this.scale.y+i)+")"})},restoreCloseStyle:function(){n(this.el,this.styleClose)},restoreOpenStyle:function(){n(this.el,this.styleOpen)},upgradeSource:function(){if(this.srcOriginal){var t=this.el.parentNode,e=this.el.cloneNode(!1);e.setAttribute("src",this.srcOriginal),e.style.position="fixed",e.style.visibility="hidden",t.appendChild(e),setTimeout(function(){this.el.setAttribute("src",this.srcOriginal),t.removeChild(e)}.bind(this),50)}},downgradeSource:function(){this.srcOriginal&&this.el.setAttribute("src",this.srcThumbnail)}},x=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},z=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:this.options.onOpen;if(!this.shown&&!this.lock){var s="string"==typeof i?document.querySelector(i):i;if("IMG"===s.tagName){this.options.onBeforeOpen&&this.options.onBeforeOpen(s),this.target.init(s,this),this.options.preloadImage||e(this.target.srcOriginal),this.shown=!0,this.lock=!0,this.target.zoomIn(),this.overlay.insert(),this.overlay.fadeIn(),t(document,"scroll",this.handler.scroll),t(document,"keydown",this.handler.keydown),this.options.closeOnWindowResize&&t(window,"resize",this.handler.resizeWindow);return t(s,g,function e(){t(s,g,e,!1),n.lock=!1,n.target.upgradeSource(),n.options.enableGrab&&f(document,n.handler,!0),o&&o(s)}),this}}}},{key:"close",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.onClose;if(this.shown&&!this.lock){var n=this.target.el;this.options.onBeforeClose&&this.options.onBeforeClose(n),this.lock=!0,this.body.style.cursor=m.default,this.overlay.fadeOut(),this.target.zoomOut(),t(document,"scroll",this.handler.scroll,!1),t(document,"keydown",this.handler.keydown,!1),this.options.closeOnWindowResize&&t(window,"resize",this.handler.resizeWindow,!1);return t(n,g,function o(){t(n,g,o,!1),e.shown=!1,e.lock=!1,e.target.downgradeSource(),e.options.enableGrab&&f(document,e.handler,!1),e.target.restoreCloseStyle(),e.overlay.remove(),i&&i(n)}),this}}},{key:"grab",value:function(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.scaleExtra,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.options.onGrab;if(this.shown&&!this.lock){var s=this.target.el;this.options.onBeforeGrab&&this.options.onBeforeGrab(s),this.released=!1,this.target.grab(e,i,n);return t(s,g,function e(){t(s,g,e,!1),o&&o(s)}),this}}},{key:"move",value:function(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.scaleExtra,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.options.onMove;if(this.shown&&!this.lock){this.released=!1,this.body.style.cursor=m.move,this.target.move(e,i,n);var s=this.target.el;return t(s,g,function e(){t(s,g,e,!1),o&&o(s)}),this}}},{key:"release",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.onRelease;if(this.shown&&!this.lock){var n=this.target.el;this.options.onBeforeRelease&&this.options.onBeforeRelease(n),this.lock=!0,this.body.style.cursor=m.default,this.target.restoreOpenStyle();return t(n,g,function o(){t(n,g,o,!1),e.lock=!1,e.released=!0,i&&i(n)}),this}}}]),n}();return t(document,"DOMContentLoaded",function(){new C}),C}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Zooming=e()}(this,function(){"use strict";function t(t,e,i){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o={passive:!1};n?t.addEventListener(e,i,o):t.removeEventListener(e,i,o)}function e(t,e){if(t){var i=new Image;i.onload=function(){e&&e(i)},i.src=t}}function i(t){return t.hasAttribute("data-original")?t.getAttribute("data-original"):"A"===t.parentNode.tagName?t.parentNode.getAttribute("href"):null}function n(t,e,i){s(e);var n=t.style,o={};for(var r in e)i&&(o[r]=n[r]||""),n[r]=e[r];return o}function o(t,e){Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(function(i){t[i]=t[i].bind(e)})}function s(t){var e=y.transitionProp,i=y.transformProp;if(t.transition){var n=t.transition;delete t.transition,t[e]=n}if(t.transform){var o=t.transform;delete t.transform,t[i]=o}}function r(t){return 0===t.button}function l(t){return t.metaKey||t.ctrlKey}function a(t){t.targetTouches.length}function h(t){return"Escape"===(t.key||t.code)||27===t.keyCode}function c(t){var e=d(),i={x:t.left+t.width/2,y:t.top+t.height/2};return{x:e.x-i.x,y:e.y-i.y}}function u(t,e,i){if(i)return{x:i.width/t.width,y:i.height/t.height};var n=t.width/2,o=t.height/2,s=d(),r={x:s.x-n,y:s.y-o},l=r.x/n,a=r.y/o,h=e+Math.min(l,a);return{x:h,y:h}}function d(){var t=document.documentElement;return{x:Math.min(t.clientWidth,window.innerWidth)/2,y:Math.min(t.clientHeight,window.innerHeight)/2}}function f(e,i,n){["mousedown","mousemove","mouseup","touchstart","touchmove","touchend"].forEach(function(o){t(e,o,i[o],n)})}var p="WebkitAppearance"in document.documentElement.style?"-webkit-":"",m={default:"auto",zoomIn:p+"zoom-in",zoomOut:p+"zoom-out",grab:p+"grab",move:"move"},y=function(t){var e={},i=["webkitTransition","transition","mozTransition"],n=["webkitTransform","transform","mozTransform"],o={transition:"transitionend",mozTransition:"transitionend",webkitTransition:"webkitTransitionEnd"};return i.some(function(i){if(void 0!==t.style[i])return e.transitionProp=i,e.transEndEvent=o[i],!0}),n.some(function(i){if(void 0!==t.style[i])return e.transformProp=i,e.transformCssProp=i.replace(/(.*)Transform/,"-$1-transform"),!0}),e}(document.createElement("div")),v=y.transformCssProp,g=y.transEndEvent,b={defaultZoomable:'img[data-action="zoom"]',enableGrab:!0,preloadImage:!1,closeOnWindowResize:!0,transitionDuration:.4,transitionTimingFunction:"cubic-bezier(0.4, 0, 0, 1)",bgColor:"rgb(255, 255, 255)",bgOpacity:1,scaleBase:1,scaleExtra:.5,scrollThreshold:40,zIndex:998,customSize:null,onOpen:null,onClose:null,onGrab:null,onMove:null,onRelease:null,onBeforeOpen:null,onBeforeClose:null,onBeforeGrab:null,onBeforeRelease:null},w={init:function(t){o(this,t)},click:function(t){if(t.preventDefault(),l(t))return window.open(this.target.srcOriginal||t.currentTarget.src,"_blank");this.shown?this.released?this.close():this.release():this.open(t.currentTarget)},scroll:function(){var t=document.documentElement||document.body.parentNode||document.body,e=window.pageXOffset||t.scrollLeft,i=window.pageYOffset||t.scrollTop;null===this.lastScrollPosition&&(this.lastScrollPosition={x:e,y:i});var n=this.lastScrollPosition.x-e,o=this.lastScrollPosition.y-i,s=this.options.scrollThreshold;(Math.abs(o)>=s||Math.abs(n)>=s)&&(this.lastScrollPosition=null,this.close())},keydown:function(t){h(t)&&(this.released?this.close():this.release(this.close))},mousedown:function(t){if(r(t)&&!l(t)){t.preventDefault();var e=t.clientX,i=t.clientY;this.pressTimer=setTimeout(function(){this.grab(e,i)}.bind(this),200)}},mousemove:function(t){this.released||this.move(t.clientX,t.clientY)},mouseup:function(t){r(t)&&!l(t)&&(clearTimeout(this.pressTimer),this.released?this.close():this.release())},touchstart:function(t){t.preventDefault();var e=t.touches[0],i=e.clientX,n=e.clientY;this.pressTimer=setTimeout(function(){this.grab(i,n)}.bind(this),200)},touchmove:function(t){if(!this.released){var e=t.touches[0],i=e.clientX,n=e.clientY;this.move(i,n)}},touchend:function(t){a(t)||(clearTimeout(this.pressTimer),this.released?this.close():this.release())},clickOverlay:function(){this.close()},resizeWindow:function(){this.close()}},O={init:function(e){this.el=document.createElement("div"),this.instance=e,this.parent=document.body,n(this.el,{position:"fixed",top:0,left:0,right:0,bottom:0,opacity:0}),this.updateStyle(e.options),t(this.el,"click",e.handler.clickOverlay.bind(e))},updateStyle:function(t){n(this.el,{zIndex:t.zIndex,backgroundColor:t.bgColor,transition:"opacity\n "+t.transitionDuration+"s\n "+t.transitionTimingFunction})},insert:function(){this.parent.appendChild(this.el)},remove:function(){this.parent.removeChild(this.el)},fadeIn:function(){this.el.offsetWidth,this.el.style.opacity=this.instance.options.bgOpacity},fadeOut:function(){this.el.style.opacity=0}},x={init:function(t,e){this.el=t,this.instance=e,this.srcThumbnail=this.el.getAttribute("src"),this.srcOriginal=i(this.el),this.rect=t.getBoundingClientRect(),this.translate=null,this.scale=null,this.styleOpen=null,this.styleClose=null},zoomIn:function(){var t=this.instance.options;this.translate=c(this.rect),this.scale=u(this.rect,t.scaleBase,t.customSize),this.styleOpen={position:"relative",zIndex:t.zIndex+1,cursor:t.enableGrab?m.grab:m.zoomOut,transition:v+"\n "+t.transitionDuration+"s\n "+t.transitionTimingFunction,transform:"translate3d("+this.translate.x+"px, "+this.translate.y+"px, 0px)\n scale("+this.scale.x+","+this.scale.y+")",height:this.rect.height+"px",width:this.rect.width+"px"},this.el.offsetWidth,this.styleClose=n(this.el,this.styleOpen,!0)},zoomOut:function(){this.el.offsetWidth,n(this.el,{transform:"none"})},grab:function(t,e,i){var o=d(),s=o.x-t,r=o.y-e;n(this.el,{cursor:m.move,transform:"translate3d(\n "+(this.translate.x+s)+"px, "+(this.translate.y+r)+"px, 0px)\n scale("+(this.scale.x+i)+","+(this.scale.y+i)+")"})},move:function(t,e,i){var o=d(),s=o.x-t,r=o.y-e;n(this.el,{transition:v,transform:"translate3d(\n "+(this.translate.x+s)+"px, "+(this.translate.y+r)+"px, 0px)\n scale("+(this.scale.x+i)+","+(this.scale.y+i)+")"})},restoreCloseStyle:function(){n(this.el,this.styleClose)},restoreOpenStyle:function(){n(this.el,this.styleOpen)},upgradeSource:function(){if(this.srcOriginal){var t=this.el.parentNode,e=this.el.cloneNode(!1);e.setAttribute("src",this.srcOriginal),e.style.position="fixed",e.style.visibility="hidden",t.appendChild(e),setTimeout(function(){this.el.setAttribute("src",this.srcOriginal),t.removeChild(e)}.bind(this),50)}},downgradeSource:function(){this.srcOriginal&&this.el.setAttribute("src",this.srcThumbnail)}},k=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},z=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:this.options.onOpen;if(!this.shown&&!this.lock){var s="string"==typeof i?document.querySelector(i):i;if("IMG"===s.tagName){this.options.onBeforeOpen&&this.options.onBeforeOpen(s),this.target.init(s,this),this.options.preloadImage||e(this.target.srcOriginal),this.shown=!0,this.lock=!0,this.target.zoomIn(),this.overlay.insert(),this.overlay.fadeIn(),t(document,"scroll",this.handler.scroll),t(document,"keydown",this.handler.keydown),this.options.closeOnWindowResize&&t(window,"resize",this.handler.resizeWindow);return t(s,g,function e(){t(s,g,e,!1),n.lock=!1,n.target.upgradeSource(),n.options.enableGrab&&f(document,n.handler,!0),o&&o(s)}),this}}}},{key:"close",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.onClose;if(this.shown&&!this.lock){var n=this.target.el;this.options.onBeforeClose&&this.options.onBeforeClose(n),this.lock=!0,this.body.style.cursor=m.default,this.overlay.fadeOut(),this.target.zoomOut(),t(document,"scroll",this.handler.scroll,!1),t(document,"keydown",this.handler.keydown,!1),this.options.closeOnWindowResize&&t(window,"resize",this.handler.resizeWindow,!1);return t(n,g,function o(){t(n,g,o,!1),e.shown=!1,e.lock=!1,e.target.downgradeSource(),e.options.enableGrab&&f(document,e.handler,!1),e.target.restoreCloseStyle(),e.overlay.remove(),i&&i(n)}),this}}},{key:"grab",value:function(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.scaleExtra,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.options.onGrab;if(this.shown&&!this.lock){var s=this.target.el;this.options.onBeforeGrab&&this.options.onBeforeGrab(s),this.released=!1,this.target.grab(e,i,n);return t(s,g,function e(){t(s,g,e,!1),o&&o(s)}),this}}},{key:"move",value:function(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.scaleExtra,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.options.onMove;if(this.shown&&!this.lock){this.released=!1,this.body.style.cursor=m.move,this.target.move(e,i,n);var s=this.target.el;return t(s,g,function e(){t(s,g,e,!1),o&&o(s)}),this}}},{key:"release",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.onRelease;if(this.shown&&!this.lock){var n=this.target.el;this.options.onBeforeRelease&&this.options.onBeforeRelease(n),this.lock=!0,this.body.style.cursor=m.default,this.target.restoreOpenStyle();return t(n,g,function o(){t(n,g,o,!1),e.lock=!1,e.released=!0,i&&i(n)}),this}}}]),n}();return t(document,"DOMContentLoaded",function(){new C}),C}); //# sourceMappingURL=zooming.min.js.map diff --git a/build/zooming.min.js.map b/build/zooming.min.js.map index ff505fb6..19010d02 100644 --- a/build/zooming.min.js.map +++ b/build/zooming.min.js.map @@ -1 +1 @@ -{"version":3,"file":"zooming.min.js","sources":["../src/utils.js","../src/modules/handler.js","../src/modules/target.js","../src/modules/zooming.js","../src/options.js","../src/modules/overlay.js","../src/index.js"],"sourcesContent":["export const webkitPrefix = 'WebkitAppearance' in document.documentElement.style\n ? '-webkit-'\n : ''\n\nexport const cursor = {\n default: 'auto',\n zoomIn: `${webkitPrefix}zoom-in`,\n zoomOut: `${webkitPrefix}zoom-out`,\n grab: `${webkitPrefix}grab`,\n move: 'move'\n}\n\nexport function listen(el, event, handler, add = true) {\n const options = { passive: false }\n\n if (add) {\n el.addEventListener(event, handler, options)\n } else {\n el.removeEventListener(event, handler, options)\n }\n}\n\nexport function loadImage(src, cb) {\n if (src) {\n const img = new Image()\n\n img.onload = function onImageLoad() {\n if (cb) cb(img)\n }\n\n img.src = src\n }\n}\n\nexport function getOriginalSource(el) {\n if (el.hasAttribute('data-original')) {\n return el.getAttribute('data-original')\n } else if (el.parentNode.tagName === 'A') {\n return el.parentNode.getAttribute('href')\n } else {\n return null\n }\n}\n\nexport function setStyle(el, styles, remember) {\n checkTrans(styles)\n\n let s = el.style\n let original = {}\n\n for (let key in styles) {\n if (remember) {\n original[key] = s[key] || ''\n }\n\n s[key] = styles[key]\n }\n\n return original\n}\n\nexport function bindAll(_this, that) {\n const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(_this))\n methods.forEach(function bindOne(method) {\n _this[method] = _this[method].bind(that)\n })\n}\n\nconst trans = sniffTransition(document.createElement('div'))\nexport const transformCssProp = trans.transformCssProp\nexport const transEndEvent = trans.transEndEvent\n\nfunction checkTrans(styles) {\n const { transitionProp, transformProp } = trans\n\n if (styles.transition) {\n const value = styles.transition\n delete styles.transition\n styles[transitionProp] = value\n }\n\n if (styles.transform) {\n const value = styles.transform\n delete styles.transform\n styles[transformProp] = value\n }\n}\n\nfunction sniffTransition(el) {\n let res = {}\n const trans = ['webkitTransition', 'transition', 'mozTransition']\n const tform = ['webkitTransform', 'transform', 'mozTransform']\n const end = {\n transition: 'transitionend',\n mozTransition: 'transitionend',\n webkitTransition: 'webkitTransitionEnd'\n }\n\n trans.some(function hasTransition(prop) {\n if (el.style[prop] !== undefined) {\n res.transitionProp = prop\n res.transEndEvent = end[prop]\n return true\n }\n })\n\n tform.some(function hasTransform(prop) {\n if (el.style[prop] !== undefined) {\n res.transformProp = prop\n res.transformCssProp = prop.replace(/(.*)Transform/, '-$1-transform')\n return true\n }\n })\n\n return res\n}\n","import { bindAll } from '../utils'\n\nconst PRESS_DELAY = 200\n\nexport default {\n init(instance) {\n bindAll(this, instance)\n },\n\n click(e) {\n e.preventDefault()\n\n if (isPressingMetaKey(e)) {\n return window.open(\n this.target.srcOriginal || e.currentTarget.src,\n '_blank'\n )\n } else {\n if (this.shown) {\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n } else {\n this.open(e.currentTarget)\n }\n }\n },\n\n scroll() {\n const el =\n document.documentElement || document.body.parentNode || document.body\n const scrollLeft = window.pageXOffset || el.scrollLeft\n const scrollTop = window.pageYOffset || el.scrollTop\n\n if (this.lastScrollPosition === null) {\n this.lastScrollPosition = {\n x: scrollLeft,\n y: scrollTop\n }\n }\n\n const deltaX = this.lastScrollPosition.x - scrollLeft\n const deltaY = this.lastScrollPosition.y - scrollTop\n const threshold = this.options.scrollThreshold\n\n if (Math.abs(deltaY) >= threshold || Math.abs(deltaX) >= threshold) {\n this.lastScrollPosition = null\n this.close()\n }\n },\n\n keydown(e) {\n if (isEscape(e)) {\n if (this.released) {\n this.close()\n } else {\n this.release(this.close)\n }\n }\n },\n\n mousedown(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n e.preventDefault()\n const { clientX, clientY } = e\n\n this.pressTimer = setTimeout(\n function grabOnMouseDown() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n mousemove(e) {\n if (this.released) return\n this.move(e.clientX, e.clientY)\n },\n\n mouseup(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n touchstart(e) {\n e.preventDefault()\n const { clientX, clientY } = e.touches[0]\n\n this.pressTimer = setTimeout(\n function grabOnTouchStart() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n touchmove(e) {\n if (this.released) return\n\n const { clientX, clientY } = e.touches[0]\n this.move(clientX, clientY)\n },\n\n touchend(e) {\n if (isTouching(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n clickOverlay() {\n this.close()\n },\n\n resizeWindow() {\n this.close()\n }\n}\n\nfunction isLeftButton(e) {\n return e.button === 0\n}\n\nfunction isPressingMetaKey(e) {\n return e.metaKey || e.ctrlKey\n}\n\nfunction isTouching(e) {\n e.targetTouches.length > 0\n}\n\nfunction isEscape(e) {\n const code = e.key || e.code\n return code === 'Escape' || e.keyCode === 27\n}\n","import { cursor, setStyle, getOriginalSource, transformCssProp } from '../utils'\n\nexport default {\n init(el, instance) {\n this.el = el\n this.instance = instance\n this.srcThumbnail = this.el.getAttribute('src')\n this.srcOriginal = getOriginalSource(this.el)\n this.rect = el.getBoundingClientRect()\n this.translate = null\n this.scale = null\n this.styleOpen = null\n this.styleClose = null\n },\n\n zoomIn() {\n const options = this.instance.options\n\n this.translate = calculateTranslate(this.rect)\n this.scale = calculateScale(\n this.rect,\n options.scaleBase,\n options.customSize\n )\n\n this.styleOpen = {\n position: 'relative',\n zIndex: options.zIndex + 1,\n cursor: options.enableGrab ? cursor.grab : cursor.zoomOut,\n transition: `${transformCssProp}\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`,\n transform: `translate(${this.translate.x}px, ${this.translate.y}px)\n scale(${this.scale.x},${this.scale.y})`,\n height: `${this.rect.height}px`,\n width: `${this.rect.width}px`\n }\n\n // Force layout update\n this.el.offsetWidth\n\n // Trigger transition\n this.styleClose = setStyle(this.el, this.styleOpen, true)\n },\n\n zoomOut() {\n // Force layout update\n this.el.offsetWidth\n\n setStyle(this.el, { transform: 'none' })\n },\n\n grab(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n cursor: cursor.move,\n transform: `translate(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n move(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n transition: transformCssProp,\n transform: `translate(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n restoreCloseStyle() {\n setStyle(this.el, this.styleClose)\n },\n\n restoreOpenStyle() {\n setStyle(this.el, this.styleOpen)\n },\n\n upgradeSource() {\n if (this.srcOriginal) {\n const parentNode = this.el.parentNode\n const temp = this.el.cloneNode(false)\n\n // Force compute the hi-res image in DOM to prevent\n // image flickering while updating src\n temp.setAttribute('src', this.srcOriginal)\n temp.style.position = 'fixed'\n temp.style.visibility = 'hidden'\n parentNode.appendChild(temp)\n\n // Add delay to prevent Firefox from flickering\n setTimeout(\n function updateSrc() {\n this.el.setAttribute('src', this.srcOriginal)\n parentNode.removeChild(temp)\n }.bind(this),\n 50\n )\n }\n },\n\n downgradeSource() {\n if (this.srcOriginal) {\n this.el.setAttribute('src', this.srcThumbnail)\n }\n }\n}\n\nfunction calculateTranslate(rect) {\n const windowCenter = getWindowCenter()\n const targetCenter = {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2\n }\n\n // The vector to translate image to the window center\n return {\n x: windowCenter.x - targetCenter.x,\n y: windowCenter.y - targetCenter.y\n }\n}\n\nfunction calculateScale(rect, scaleBase, customSize) {\n if (customSize) {\n return {\n x: customSize.width / rect.width,\n y: customSize.height / rect.height\n }\n } else {\n const targetHalfWidth = rect.width / 2\n const targetHalfHeight = rect.height / 2\n const windowCenter = getWindowCenter()\n\n // The distance between target edge and window edge\n const targetEdgeToWindowEdge = {\n x: windowCenter.x - targetHalfWidth,\n y: windowCenter.y - targetHalfHeight\n }\n\n const scaleHorizontally = targetEdgeToWindowEdge.x / targetHalfWidth\n const scaleVertically = targetEdgeToWindowEdge.y / targetHalfHeight\n\n // The additional scale is based on the smaller value of\n // scaling horizontally and scaling vertically\n const scale = scaleBase + Math.min(scaleHorizontally, scaleVertically)\n\n return {\n x: scale,\n y: scale\n }\n }\n}\n\nfunction getWindowCenter() {\n const docEl = document.documentElement\n const windowWidth = Math.min(docEl.clientWidth, window.innerWidth)\n const windowHeight = Math.min(docEl.clientHeight, window.innerHeight)\n\n return {\n x: windowWidth / 2,\n y: windowHeight / 2\n }\n}\n","import {\n cursor,\n listen,\n loadImage,\n transEndEvent,\n getOriginalSource\n} from '../utils'\nimport DEFAULT_OPTIONS from '../options'\n\nimport handler from './handler'\nimport overlay from './overlay'\nimport target from './target'\n\n/**\n * Zooming instance.\n */\nexport default class Zooming {\n /**\n * @param {Object} [options] Update default options if provided.\n */\n constructor(options) {\n this.target = Object.create(target)\n this.overlay = Object.create(overlay)\n this.handler = Object.create(handler)\n this.body = document.body\n\n this.shown = false\n this.lock = false\n this.released = true\n this.lastScrollPosition = null\n this.pressTimer = null\n\n this.options = Object.assign({}, DEFAULT_OPTIONS, options)\n this.overlay.init(this)\n this.handler.init(this)\n this.listen(this.options.defaultZoomable)\n }\n\n /**\n * Make element(s) zoomable.\n * @param {string|Element} el A css selector or an Element.\n * @return {this}\n */\n listen(el) {\n if (typeof el === 'string') {\n const els = document.querySelectorAll(el)\n let i = els.length\n\n while (i--) {\n this.listen(els[i])\n }\n } else if (el.tagName === 'IMG') {\n el.style.cursor = cursor.zoomIn\n listen(el, 'click', this.handler.click)\n\n if (this.options.preloadImage) {\n loadImage(getOriginalSource(el))\n }\n }\n\n return this\n }\n\n /**\n * Update options or return current options if no argument is provided.\n * @param {Object} options An Object that contains this.options.\n * @return {this|this.options}\n */\n config(options) {\n if (options) {\n Object.assign(this.options, options)\n this.overlay.updateStyle(this.options)\n return this\n } else {\n return this.options\n }\n }\n\n /**\n * Open (zoom in) the Element.\n * @param {Element} el The Element to open.\n * @param {Function} [cb=this.options.onOpen] A callback function that will\n * be called when a target is opened and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n open(el, cb = this.options.onOpen) {\n if (this.shown || this.lock) return\n\n const target = typeof el === 'string' ? document.querySelector(el) : el\n\n if (target.tagName !== 'IMG') return\n\n if (this.options.onBeforeOpen) {\n this.options.onBeforeOpen(target)\n }\n\n this.target.init(target, this)\n\n if (!this.options.preloadImage) {\n loadImage(this.target.srcOriginal)\n }\n\n this.shown = true\n this.lock = true\n\n this.target.zoomIn()\n this.overlay.insert()\n this.overlay.fadeIn()\n\n listen(document, 'scroll', this.handler.scroll)\n listen(document, 'keydown', this.handler.keydown)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow)\n }\n\n const onOpenEnd = () => {\n listen(target, transEndEvent, onOpenEnd, false)\n this.lock = false\n this.target.upgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, true)\n }\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onOpenEnd)\n\n return this\n }\n\n /**\n * Close (zoom out) the Element currently opened.\n * @param {Function} [cb=this.options.onClose] A callback function that will\n * be called when a target is closed and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n close(cb = this.options.onClose) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeClose) {\n this.options.onBeforeClose(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.overlay.fadeOut()\n this.target.zoomOut()\n\n listen(document, 'scroll', this.handler.scroll, false)\n listen(document, 'keydown', this.handler.keydown, false)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow, false)\n }\n\n const onCloseEnd = () => {\n listen(target, transEndEvent, onCloseEnd, false)\n\n this.shown = false\n this.lock = false\n\n this.target.downgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, false)\n }\n\n this.target.restoreCloseStyle()\n this.overlay.remove()\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onCloseEnd)\n\n return this\n }\n\n /**\n * Grab the Element currently opened given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onGrab] A callback function that\n * will be called when a target is grabbed and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n grab(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onGrab) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeGrab) {\n this.options.onBeforeGrab(target)\n }\n\n this.released = false\n this.target.grab(x, y, scaleExtra)\n\n const onGrabEnd = () => {\n listen(target, transEndEvent, onGrabEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onGrabEnd)\n\n return this\n }\n\n /**\n * Move the Element currently grabbed given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onMove] A callback function that\n * will be called when a target is moved and transition has ended. It will\n * get the target element as the argument.\n * @return {this}\n */\n move(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onMove) {\n if (!this.shown || this.lock) return\n\n this.released = false\n this.body.style.cursor = cursor.move\n this.target.move(x, y, scaleExtra)\n\n const target = this.target.el\n\n const onMoveEnd = () => {\n listen(target, transEndEvent, onMoveEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onMoveEnd)\n\n return this\n }\n\n /**\n * Release the Element currently grabbed.\n * @param {Function} [cb=this.options.onRelease] A callback function that\n * will be called when a target is released and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n release(cb = this.options.onRelease) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeRelease) {\n this.options.onBeforeRelease(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.target.restoreOpenStyle()\n\n const onReleaseEnd = () => {\n listen(target, transEndEvent, onReleaseEnd, false)\n this.lock = false\n this.released = true\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onReleaseEnd)\n\n return this\n }\n}\n\nfunction toggleGrabListeners(el, handler, add) {\n const types = [\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'touchstart',\n 'touchmove',\n 'touchend'\n ]\n\n types.forEach(function toggleListener(type) {\n listen(el, type, handler[type], add)\n })\n}\n","/**\n * A list of options.\n *\n * @type {Object}\n * @example\n * // Default options\n * const options = {\n * defaultZoomable: 'img[data-action=\"zoom\"]',\n * enableGrab: true,\n * preloadImage: false,\n * closeOnWindowResize: true,\n * transitionDuration: 0.4,\n * transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)',\n * bgColor: 'rgb(255, 255, 255)',\n * bgOpacity: 1,\n * scaleBase: 1.0,\n * scaleExtra: 0.5,\n * scrollThreshold: 40,\n * zIndex: 998,\n * customSize: null,\n * onOpen: null,\n * onClose: null,\n * onRelease: null,\n * onBeforeOpen: null,\n * onBeforeClose: null,\n * onBeforeGrab: null,\n * onBeforeRelease: null\n * }\n */\nexport default {\n /**\n * Zoomable elements by default. It can be a css selector or an element.\n * @type {string|Element}\n */\n defaultZoomable: 'img[data-action=\"zoom\"]',\n\n /**\n * To be able to grab and drag the image for extra zoom-in.\n * @type {boolean}\n */\n enableGrab: true,\n\n /**\n * Preload zoomable images.\n * @type {boolean}\n */\n preloadImage: false,\n\n /**\n * Close the zoomed image when browser window is resized.\n * @type {boolean}\n */\n closeOnWindowResize: true,\n\n /**\n * Transition duration in seconds.\n * @type {number}\n */\n transitionDuration: 0.4,\n\n /**\n * Transition timing function.\n * @type {string}\n */\n transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)',\n\n /**\n * Overlay background color.\n * @type {string}\n */\n bgColor: 'rgb(255, 255, 255)',\n\n /**\n * Overlay background opacity.\n * @type {number}\n */\n bgOpacity: 1,\n\n /**\n * The base scale factor for zooming. By default scale to fit the window.\n * @type {number}\n */\n scaleBase: 1.0,\n\n /**\n * The additional scale factor when grabbing the image.\n * @type {number}\n */\n scaleExtra: 0.5,\n\n /**\n * How much scrolling it takes before closing out.\n * @type {number}\n */\n scrollThreshold: 40,\n\n /**\n * The z-index that the overlay will be added with.\n * @type {number}\n */\n zIndex: 998,\n\n /**\n * Scale (zoom in) to given width and height. Ignore scaleBase if set.\n * @type {Object}\n * @example\n * customSize: { width: 800, height: 400 }\n */\n customSize: null,\n\n /**\n * A callback function that will be called when a target is opened and\n * transition has ended. It will get the target element as the argument.\n * @type {Function}\n */\n onOpen: null,\n\n /**\n * Same as above, except fired when closed.\n * @type {Function}\n */\n onClose: null,\n\n /**\n * Same as above, except fired when grabbed.\n * @type {Function}\n */\n onGrab: null,\n\n /**\n * Same as above, except fired when moved.\n * @type {Function}\n */\n onMove: null,\n\n /**\n * Same as above, except fired when released.\n * @type {Function}\n */\n onRelease: null,\n\n /**\n * A callback function that will be called before open.\n * @type {Function}\n */\n onBeforeOpen: null,\n\n /**\n * A callback function that will be called before close.\n * @type {Function}\n */\n onBeforeClose: null,\n\n /**\n * A callback function that will be called before grab.\n * @type {Function}\n */\n onBeforeGrab: null,\n\n /**\n * A callback function that will be called before release.\n * @type {Function}\n */\n onBeforeRelease: null\n}\n","import { listen, setStyle } from '../utils'\n\nexport default {\n init(instance) {\n this.el = document.createElement('div')\n this.instance = instance\n this.parent = document.body\n\n setStyle(this.el, {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: 0\n })\n\n this.updateStyle(instance.options)\n listen(this.el, 'click', instance.handler.clickOverlay.bind(instance))\n },\n\n updateStyle(options) {\n setStyle(this.el, {\n zIndex: options.zIndex,\n backgroundColor: options.bgColor,\n transition: `opacity\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`\n })\n },\n\n insert() {\n this.parent.appendChild(this.el)\n },\n\n remove() {\n this.parent.removeChild(this.el)\n },\n\n fadeIn() {\n this.el.offsetWidth\n this.el.style.opacity = this.instance.options.bgOpacity\n },\n\n fadeOut() {\n this.el.style.opacity = 0\n }\n}\n","import { listen } from './utils'\nimport Zooming from './modules/zooming'\n\nlisten(document, 'DOMContentLoaded', function initZooming() {\n new Zooming()\n})\n\nexport default Zooming\n"],"names":["listen","el","event","handler","add","options","passive","addEventListener","removeEventListener","loadImage","src","cb","img","Image","onload","getOriginalSource","hasAttribute","getAttribute","parentNode","tagName","setStyle","styles","remember","s","style","original","key","bindAll","_this","that","Object","getOwnPropertyNames","getPrototypeOf","forEach","method","bind","checkTrans","transitionProp","trans","transformProp","transition","value","transform","isLeftButton","e","button","isPressingMetaKey","metaKey","ctrlKey","isTouching","targetTouches","length","isEscape","code","keyCode","calculateTranslate","rect","windowCenter","getWindowCenter","targetCenter","left","width","top","height","x","y","calculateScale","scaleBase","customSize","targetHalfWidth","targetHalfHeight","targetEdgeToWindowEdge","scaleHorizontally","scaleVertically","scale","Math","min","docEl","document","documentElement","clientWidth","window","innerWidth","clientHeight","innerHeight","toggleGrabListeners","type","webkitPrefix","cursor","res","tform","end","some","prop","undefined","transEndEvent","transformCssProp","replace","createElement","instance","this","preventDefault","open","target","srcOriginal","currentTarget","shown","released","close","release","body","scrollLeft","pageXOffset","scrollTop","pageYOffset","lastScrollPosition","deltaX","deltaY","threshold","scrollThreshold","abs","clientX","clientY","pressTimer","setTimeout","grab","move","touches","parent","updateStyle","clickOverlay","zIndex","bgColor","transitionDuration","transitionTimingFunction","appendChild","removeChild","offsetWidth","opacity","bgOpacity","srcThumbnail","getBoundingClientRect","translate","styleOpen","styleClose","enableGrab","zoomOut","scaleExtra","dx","dy","temp","cloneNode","setAttribute","position","visibility","Zooming","create","overlay","lock","babelHelpers.extends","DEFAULT_OPTIONS","init","defaultZoomable","els","querySelectorAll","i","zoomIn","click","preloadImage","onOpen","querySelector","onBeforeOpen","insert","fadeIn","scroll","keydown","closeOnWindowResize","resizeWindow","onOpenEnd","upgradeSource","onClose","onBeforeClose","default","fadeOut","onCloseEnd","downgradeSource","_this2","restoreCloseStyle","remove","onGrab","onBeforeGrab","onGrabEnd","onMove","onMoveEnd","onRelease","onBeforeRelease","restoreOpenStyle","onReleaseEnd"],"mappings":"kLAYA,SAAgBA,GAAOC,EAAIC,EAAOC,MAASC,8DACnCC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GAAIA,EAAG4F,KAKNH,mDAUDzF,yDAAKyF,KAAK/F,QAAQ6L,aACnB9F,KAAKM,QAASN,KAAK0D,SAElBvD,GAASH,KAAKG,OAAOtG,EAEvBmG,MAAK/F,QAAQ8L,sBACV9L,QAAQ8L,gBAAgB5F,QAG1BuD,MAAO,OACPhD,KAAKtF,MAAMgE,OAASA,EAAO8F,aAC3B/E,OAAO6F,4BAUL7F,EAAQR,EARM,QAAfsG,OACG9F,EAAQR,EAAesG,GAAc,KACvCvC,MAAO,IACPnD,UAAW,EAEZhG,GAAIA,EAAG4F,KAKNH,qBGjRXpG,GAAO8E,SAAU,mBAAoB,cAC/B6E"} \ No newline at end of file +{"version":3,"file":"zooming.min.js","sources":["../src/utils.js","../src/modules/handler.js","../src/modules/target.js","../src/modules/zooming.js","../src/options.js","../src/modules/overlay.js","../src/index.js"],"sourcesContent":["export const webkitPrefix = 'WebkitAppearance' in document.documentElement.style\n ? '-webkit-'\n : ''\n\nexport const cursor = {\n default: 'auto',\n zoomIn: `${webkitPrefix}zoom-in`,\n zoomOut: `${webkitPrefix}zoom-out`,\n grab: `${webkitPrefix}grab`,\n move: 'move'\n}\n\nexport function listen(el, event, handler, add = true) {\n const options = { passive: false }\n\n if (add) {\n el.addEventListener(event, handler, options)\n } else {\n el.removeEventListener(event, handler, options)\n }\n}\n\nexport function loadImage(src, cb) {\n if (src) {\n const img = new Image()\n\n img.onload = function onImageLoad() {\n if (cb) cb(img)\n }\n\n img.src = src\n }\n}\n\nexport function getOriginalSource(el) {\n if (el.hasAttribute('data-original')) {\n return el.getAttribute('data-original')\n } else if (el.parentNode.tagName === 'A') {\n return el.parentNode.getAttribute('href')\n } else {\n return null\n }\n}\n\nexport function setStyle(el, styles, remember) {\n checkTrans(styles)\n\n let s = el.style\n let original = {}\n\n for (let key in styles) {\n if (remember) {\n original[key] = s[key] || ''\n }\n\n s[key] = styles[key]\n }\n\n return original\n}\n\nexport function bindAll(_this, that) {\n const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(_this))\n methods.forEach(function bindOne(method) {\n _this[method] = _this[method].bind(that)\n })\n}\n\nconst trans = sniffTransition(document.createElement('div'))\nexport const transformCssProp = trans.transformCssProp\nexport const transEndEvent = trans.transEndEvent\n\nfunction checkTrans(styles) {\n const { transitionProp, transformProp } = trans\n\n if (styles.transition) {\n const value = styles.transition\n delete styles.transition\n styles[transitionProp] = value\n }\n\n if (styles.transform) {\n const value = styles.transform\n delete styles.transform\n styles[transformProp] = value\n }\n}\n\nfunction sniffTransition(el) {\n let res = {}\n const trans = ['webkitTransition', 'transition', 'mozTransition']\n const tform = ['webkitTransform', 'transform', 'mozTransform']\n const end = {\n transition: 'transitionend',\n mozTransition: 'transitionend',\n webkitTransition: 'webkitTransitionEnd'\n }\n\n trans.some(function hasTransition(prop) {\n if (el.style[prop] !== undefined) {\n res.transitionProp = prop\n res.transEndEvent = end[prop]\n return true\n }\n })\n\n tform.some(function hasTransform(prop) {\n if (el.style[prop] !== undefined) {\n res.transformProp = prop\n res.transformCssProp = prop.replace(/(.*)Transform/, '-$1-transform')\n return true\n }\n })\n\n return res\n}\n","import { bindAll } from '../utils'\n\nconst PRESS_DELAY = 200\n\nexport default {\n init(instance) {\n bindAll(this, instance)\n },\n\n click(e) {\n e.preventDefault()\n\n if (isPressingMetaKey(e)) {\n return window.open(\n this.target.srcOriginal || e.currentTarget.src,\n '_blank'\n )\n } else {\n if (this.shown) {\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n } else {\n this.open(e.currentTarget)\n }\n }\n },\n\n scroll() {\n const el =\n document.documentElement || document.body.parentNode || document.body\n const scrollLeft = window.pageXOffset || el.scrollLeft\n const scrollTop = window.pageYOffset || el.scrollTop\n\n if (this.lastScrollPosition === null) {\n this.lastScrollPosition = {\n x: scrollLeft,\n y: scrollTop\n }\n }\n\n const deltaX = this.lastScrollPosition.x - scrollLeft\n const deltaY = this.lastScrollPosition.y - scrollTop\n const threshold = this.options.scrollThreshold\n\n if (Math.abs(deltaY) >= threshold || Math.abs(deltaX) >= threshold) {\n this.lastScrollPosition = null\n this.close()\n }\n },\n\n keydown(e) {\n if (isEscape(e)) {\n if (this.released) {\n this.close()\n } else {\n this.release(this.close)\n }\n }\n },\n\n mousedown(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n e.preventDefault()\n const { clientX, clientY } = e\n\n this.pressTimer = setTimeout(\n function grabOnMouseDown() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n mousemove(e) {\n if (this.released) return\n this.move(e.clientX, e.clientY)\n },\n\n mouseup(e) {\n if (!isLeftButton(e) || isPressingMetaKey(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n touchstart(e) {\n e.preventDefault()\n const { clientX, clientY } = e.touches[0]\n\n this.pressTimer = setTimeout(\n function grabOnTouchStart() {\n this.grab(clientX, clientY)\n }.bind(this),\n PRESS_DELAY\n )\n },\n\n touchmove(e) {\n if (this.released) return\n\n const { clientX, clientY } = e.touches[0]\n this.move(clientX, clientY)\n },\n\n touchend(e) {\n if (isTouching(e)) return\n clearTimeout(this.pressTimer)\n\n if (this.released) {\n this.close()\n } else {\n this.release()\n }\n },\n\n clickOverlay() {\n this.close()\n },\n\n resizeWindow() {\n this.close()\n }\n}\n\nfunction isLeftButton(e) {\n return e.button === 0\n}\n\nfunction isPressingMetaKey(e) {\n return e.metaKey || e.ctrlKey\n}\n\nfunction isTouching(e) {\n e.targetTouches.length > 0\n}\n\nfunction isEscape(e) {\n const code = e.key || e.code\n return code === 'Escape' || e.keyCode === 27\n}\n","import { cursor, setStyle, getOriginalSource, transformCssProp } from '../utils'\n\n// Translate z-axis to fix CSS grid display issue in Chrome:\n// https://github.com/kingdido999/zooming/issues/42 \nconst TRANSLATE_Z = 0\n\nexport default {\n init(el, instance) {\n this.el = el\n this.instance = instance\n this.srcThumbnail = this.el.getAttribute('src')\n this.srcOriginal = getOriginalSource(this.el)\n this.rect = el.getBoundingClientRect()\n this.translate = null\n this.scale = null\n this.styleOpen = null\n this.styleClose = null\n },\n\n zoomIn() {\n const options = this.instance.options\n\n this.translate = calculateTranslate(this.rect)\n this.scale = calculateScale(\n this.rect,\n options.scaleBase,\n options.customSize\n )\n\n this.styleOpen = {\n position: 'relative',\n zIndex: options.zIndex + 1,\n cursor: options.enableGrab ? cursor.grab : cursor.zoomOut,\n transition: `${transformCssProp}\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`,\n transform: `translate3d(${this.translate.x}px, ${this.translate.y}px, ${TRANSLATE_Z}px)\n scale(${this.scale.x},${this.scale.y})`,\n height: `${this.rect.height}px`,\n width: `${this.rect.width}px`\n }\n\n // Force layout update\n this.el.offsetWidth\n\n // Trigger transition\n this.styleClose = setStyle(this.el, this.styleOpen, true)\n },\n\n zoomOut() {\n // Force layout update\n this.el.offsetWidth\n\n setStyle(this.el, { transform: 'none' })\n },\n\n grab(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n cursor: cursor.move,\n transform: `translate3d(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px, ${TRANSLATE_Z}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n move(x, y, scaleExtra) {\n const windowCenter = getWindowCenter()\n const [dx, dy] = [windowCenter.x - x, windowCenter.y - y]\n\n setStyle(this.el, {\n transition: transformCssProp,\n transform: `translate3d(\n ${this.translate.x + dx}px, ${this.translate.y + dy}px, ${TRANSLATE_Z}px)\n scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})`\n })\n },\n\n restoreCloseStyle() {\n setStyle(this.el, this.styleClose)\n },\n\n restoreOpenStyle() {\n setStyle(this.el, this.styleOpen)\n },\n\n upgradeSource() {\n if (this.srcOriginal) {\n const parentNode = this.el.parentNode\n const temp = this.el.cloneNode(false)\n\n // Force compute the hi-res image in DOM to prevent\n // image flickering while updating src\n temp.setAttribute('src', this.srcOriginal)\n temp.style.position = 'fixed'\n temp.style.visibility = 'hidden'\n parentNode.appendChild(temp)\n\n // Add delay to prevent Firefox from flickering\n setTimeout(\n function updateSrc() {\n this.el.setAttribute('src', this.srcOriginal)\n parentNode.removeChild(temp)\n }.bind(this),\n 50\n )\n }\n },\n\n downgradeSource() {\n if (this.srcOriginal) {\n this.el.setAttribute('src', this.srcThumbnail)\n }\n }\n}\n\nfunction calculateTranslate(rect) {\n const windowCenter = getWindowCenter()\n const targetCenter = {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2\n }\n\n // The vector to translate image to the window center\n return {\n x: windowCenter.x - targetCenter.x,\n y: windowCenter.y - targetCenter.y\n }\n}\n\nfunction calculateScale(rect, scaleBase, customSize) {\n if (customSize) {\n return {\n x: customSize.width / rect.width,\n y: customSize.height / rect.height\n }\n } else {\n const targetHalfWidth = rect.width / 2\n const targetHalfHeight = rect.height / 2\n const windowCenter = getWindowCenter()\n\n // The distance between target edge and window edge\n const targetEdgeToWindowEdge = {\n x: windowCenter.x - targetHalfWidth,\n y: windowCenter.y - targetHalfHeight\n }\n\n const scaleHorizontally = targetEdgeToWindowEdge.x / targetHalfWidth\n const scaleVertically = targetEdgeToWindowEdge.y / targetHalfHeight\n\n // The additional scale is based on the smaller value of\n // scaling horizontally and scaling vertically\n const scale = scaleBase + Math.min(scaleHorizontally, scaleVertically)\n\n return {\n x: scale,\n y: scale\n }\n }\n}\n\nfunction getWindowCenter() {\n const docEl = document.documentElement\n const windowWidth = Math.min(docEl.clientWidth, window.innerWidth)\n const windowHeight = Math.min(docEl.clientHeight, window.innerHeight)\n\n return {\n x: windowWidth / 2,\n y: windowHeight / 2\n }\n}\n","import {\n cursor,\n listen,\n loadImage,\n transEndEvent,\n getOriginalSource\n} from '../utils'\nimport DEFAULT_OPTIONS from '../options'\n\nimport handler from './handler'\nimport overlay from './overlay'\nimport target from './target'\n\n/**\n * Zooming instance.\n */\nexport default class Zooming {\n /**\n * @param {Object} [options] Update default options if provided.\n */\n constructor(options) {\n this.target = Object.create(target)\n this.overlay = Object.create(overlay)\n this.handler = Object.create(handler)\n this.body = document.body\n\n this.shown = false\n this.lock = false\n this.released = true\n this.lastScrollPosition = null\n this.pressTimer = null\n\n this.options = Object.assign({}, DEFAULT_OPTIONS, options)\n this.overlay.init(this)\n this.handler.init(this)\n this.listen(this.options.defaultZoomable)\n }\n\n /**\n * Make element(s) zoomable.\n * @param {string|Element} el A css selector or an Element.\n * @return {this}\n */\n listen(el) {\n if (typeof el === 'string') {\n const els = document.querySelectorAll(el)\n let i = els.length\n\n while (i--) {\n this.listen(els[i])\n }\n } else if (el.tagName === 'IMG') {\n el.style.cursor = cursor.zoomIn\n listen(el, 'click', this.handler.click)\n\n if (this.options.preloadImage) {\n loadImage(getOriginalSource(el))\n }\n }\n\n return this\n }\n\n /**\n * Update options or return current options if no argument is provided.\n * @param {Object} options An Object that contains this.options.\n * @return {this|this.options}\n */\n config(options) {\n if (options) {\n Object.assign(this.options, options)\n this.overlay.updateStyle(this.options)\n return this\n } else {\n return this.options\n }\n }\n\n /**\n * Open (zoom in) the Element.\n * @param {Element} el The Element to open.\n * @param {Function} [cb=this.options.onOpen] A callback function that will\n * be called when a target is opened and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n open(el, cb = this.options.onOpen) {\n if (this.shown || this.lock) return\n\n const target = typeof el === 'string' ? document.querySelector(el) : el\n\n if (target.tagName !== 'IMG') return\n\n if (this.options.onBeforeOpen) {\n this.options.onBeforeOpen(target)\n }\n\n this.target.init(target, this)\n\n if (!this.options.preloadImage) {\n loadImage(this.target.srcOriginal)\n }\n\n this.shown = true\n this.lock = true\n\n this.target.zoomIn()\n this.overlay.insert()\n this.overlay.fadeIn()\n\n listen(document, 'scroll', this.handler.scroll)\n listen(document, 'keydown', this.handler.keydown)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow)\n }\n\n const onOpenEnd = () => {\n listen(target, transEndEvent, onOpenEnd, false)\n this.lock = false\n this.target.upgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, true)\n }\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onOpenEnd)\n\n return this\n }\n\n /**\n * Close (zoom out) the Element currently opened.\n * @param {Function} [cb=this.options.onClose] A callback function that will\n * be called when a target is closed and transition has ended. It will get\n * the target element as the argument.\n * @return {this}\n */\n close(cb = this.options.onClose) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeClose) {\n this.options.onBeforeClose(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.overlay.fadeOut()\n this.target.zoomOut()\n\n listen(document, 'scroll', this.handler.scroll, false)\n listen(document, 'keydown', this.handler.keydown, false)\n\n if (this.options.closeOnWindowResize) {\n listen(window, 'resize', this.handler.resizeWindow, false)\n }\n\n const onCloseEnd = () => {\n listen(target, transEndEvent, onCloseEnd, false)\n\n this.shown = false\n this.lock = false\n\n this.target.downgradeSource()\n\n if (this.options.enableGrab) {\n toggleGrabListeners(document, this.handler, false)\n }\n\n this.target.restoreCloseStyle()\n this.overlay.remove()\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onCloseEnd)\n\n return this\n }\n\n /**\n * Grab the Element currently opened given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onGrab] A callback function that\n * will be called when a target is grabbed and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n grab(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onGrab) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeGrab) {\n this.options.onBeforeGrab(target)\n }\n\n this.released = false\n this.target.grab(x, y, scaleExtra)\n\n const onGrabEnd = () => {\n listen(target, transEndEvent, onGrabEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onGrabEnd)\n\n return this\n }\n\n /**\n * Move the Element currently grabbed given a position and apply extra zoom-in.\n * @param {number} x The X-axis of where the press happened.\n * @param {number} y The Y-axis of where the press happened.\n * @param {number} scaleExtra Extra zoom-in to apply.\n * @param {Function} [cb=this.options.onMove] A callback function that\n * will be called when a target is moved and transition has ended. It will\n * get the target element as the argument.\n * @return {this}\n */\n move(x, y, scaleExtra = this.options.scaleExtra, cb = this.options.onMove) {\n if (!this.shown || this.lock) return\n\n this.released = false\n this.body.style.cursor = cursor.move\n this.target.move(x, y, scaleExtra)\n\n const target = this.target.el\n\n const onMoveEnd = () => {\n listen(target, transEndEvent, onMoveEnd, false)\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onMoveEnd)\n\n return this\n }\n\n /**\n * Release the Element currently grabbed.\n * @param {Function} [cb=this.options.onRelease] A callback function that\n * will be called when a target is released and transition has ended. It\n * will get the target element as the argument.\n * @return {this}\n */\n release(cb = this.options.onRelease) {\n if (!this.shown || this.lock) return\n\n const target = this.target.el\n\n if (this.options.onBeforeRelease) {\n this.options.onBeforeRelease(target)\n }\n\n this.lock = true\n this.body.style.cursor = cursor.default\n this.target.restoreOpenStyle()\n\n const onReleaseEnd = () => {\n listen(target, transEndEvent, onReleaseEnd, false)\n this.lock = false\n this.released = true\n\n if (cb) cb(target)\n }\n\n listen(target, transEndEvent, onReleaseEnd)\n\n return this\n }\n}\n\nfunction toggleGrabListeners(el, handler, add) {\n const types = [\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'touchstart',\n 'touchmove',\n 'touchend'\n ]\n\n types.forEach(function toggleListener(type) {\n listen(el, type, handler[type], add)\n })\n}\n","export default {\n /**\n * Zoomable elements by default. It can be a css selector or an element.\n * @type {string|Element}\n */\n defaultZoomable: 'img[data-action=\"zoom\"]',\n\n /**\n * To be able to grab and drag the image for extra zoom-in.\n * @type {boolean}\n */\n enableGrab: true,\n\n /**\n * Preload zoomable images.\n * @type {boolean}\n */\n preloadImage: false,\n\n /**\n * Close the zoomed image when browser window is resized.\n * @type {boolean}\n */\n closeOnWindowResize: true,\n\n /**\n * Transition duration in seconds.\n * @type {number}\n */\n transitionDuration: 0.4,\n\n /**\n * Transition timing function.\n * @type {string}\n */\n transitionTimingFunction: 'cubic-bezier(0.4, 0, 0, 1)',\n\n /**\n * Overlay background color.\n * @type {string}\n */\n bgColor: 'rgb(255, 255, 255)',\n\n /**\n * Overlay background opacity.\n * @type {number}\n */\n bgOpacity: 1,\n\n /**\n * The base scale factor for zooming. By default scale to fit the window.\n * @type {number}\n */\n scaleBase: 1.0,\n\n /**\n * The additional scale factor when grabbing the image.\n * @type {number}\n */\n scaleExtra: 0.5,\n\n /**\n * How much scrolling it takes before closing out.\n * @type {number}\n */\n scrollThreshold: 40,\n\n /**\n * The z-index that the overlay will be added with.\n * @type {number}\n */\n zIndex: 998,\n\n /**\n * Scale (zoom in) to given width and height. Ignore scaleBase if set.\n * @type {Object}\n * @example\n * customSize: { width: 800, height: 400 }\n */\n customSize: null,\n\n /**\n * A callback function that will be called when a target is opened and\n * transition has ended. It will get the target element as the argument.\n * @type {Function}\n */\n onOpen: null,\n\n /**\n * Same as above, except fired when closed.\n * @type {Function}\n */\n onClose: null,\n\n /**\n * Same as above, except fired when grabbed.\n * @type {Function}\n */\n onGrab: null,\n\n /**\n * Same as above, except fired when moved.\n * @type {Function}\n */\n onMove: null,\n\n /**\n * Same as above, except fired when released.\n * @type {Function}\n */\n onRelease: null,\n\n /**\n * A callback function that will be called before open.\n * @type {Function}\n */\n onBeforeOpen: null,\n\n /**\n * A callback function that will be called before close.\n * @type {Function}\n */\n onBeforeClose: null,\n\n /**\n * A callback function that will be called before grab.\n * @type {Function}\n */\n onBeforeGrab: null,\n\n /**\n * A callback function that will be called before release.\n * @type {Function}\n */\n onBeforeRelease: null\n}\n","import { listen, setStyle } from '../utils'\n\nexport default {\n init(instance) {\n this.el = document.createElement('div')\n this.instance = instance\n this.parent = document.body\n\n setStyle(this.el, {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: 0\n })\n\n this.updateStyle(instance.options)\n listen(this.el, 'click', instance.handler.clickOverlay.bind(instance))\n },\n\n updateStyle(options) {\n setStyle(this.el, {\n zIndex: options.zIndex,\n backgroundColor: options.bgColor,\n transition: `opacity\n ${options.transitionDuration}s\n ${options.transitionTimingFunction}`\n })\n },\n\n insert() {\n this.parent.appendChild(this.el)\n },\n\n remove() {\n this.parent.removeChild(this.el)\n },\n\n fadeIn() {\n this.el.offsetWidth\n this.el.style.opacity = this.instance.options.bgOpacity\n },\n\n fadeOut() {\n this.el.style.opacity = 0\n }\n}\n","import { listen } from './utils'\nimport Zooming from './modules/zooming'\n\nlisten(document, 'DOMContentLoaded', function initZooming() {\n new Zooming()\n})\n\nexport default Zooming\n"],"names":["listen","el","event","handler","add","options","passive","addEventListener","removeEventListener","loadImage","src","cb","img","Image","onload","getOriginalSource","hasAttribute","getAttribute","parentNode","tagName","setStyle","styles","remember","s","style","original","key","bindAll","_this","that","Object","getOwnPropertyNames","getPrototypeOf","forEach","method","bind","checkTrans","transitionProp","trans","transformProp","transition","value","transform","isLeftButton","e","button","isPressingMetaKey","metaKey","ctrlKey","isTouching","targetTouches","length","isEscape","code","keyCode","calculateTranslate","rect","windowCenter","getWindowCenter","targetCenter","left","width","top","height","x","y","calculateScale","scaleBase","customSize","targetHalfWidth","targetHalfHeight","targetEdgeToWindowEdge","scaleHorizontally","scaleVertically","scale","Math","min","docEl","document","documentElement","clientWidth","window","innerWidth","clientHeight","innerHeight","toggleGrabListeners","type","webkitPrefix","cursor","res","tform","end","some","prop","undefined","transEndEvent","transformCssProp","replace","createElement","instance","this","preventDefault","open","target","srcOriginal","currentTarget","shown","released","close","release","body","scrollLeft","pageXOffset","scrollTop","pageYOffset","lastScrollPosition","deltaX","deltaY","threshold","scrollThreshold","abs","clientX","clientY","pressTimer","setTimeout","grab","move","touches","parent","updateStyle","clickOverlay","zIndex","bgColor","transitionDuration","transitionTimingFunction","appendChild","removeChild","offsetWidth","opacity","bgOpacity","srcThumbnail","getBoundingClientRect","translate","styleOpen","styleClose","enableGrab","zoomOut","scaleExtra","dx","dy","temp","cloneNode","setAttribute","position","visibility","Zooming","create","overlay","lock","babelHelpers.extends","DEFAULT_OPTIONS","init","defaultZoomable","els","querySelectorAll","i","zoomIn","click","preloadImage","onOpen","querySelector","onBeforeOpen","insert","fadeIn","scroll","keydown","closeOnWindowResize","resizeWindow","onOpenEnd","upgradeSource","onClose","onBeforeClose","default","fadeOut","onCloseEnd","downgradeSource","_this2","restoreCloseStyle","remove","onGrab","onBeforeGrab","onGrabEnd","onMove","onMoveEnd","onRelease","onBeforeRelease","restoreOpenStyle","onReleaseEnd"],"mappings":"kLAYA,SAAgBA,GAAOC,EAAIC,EAAOC,MAASC,8DACnCC,GAAYC,SAAS,EAEvBF,KACCG,iBAAiBL,EAAOC,EAASE,KAEjCG,oBAAoBN,EAAOC,EAASE,GAI3C,QAAgBI,GAAUC,EAAKC,MACzBD,EAAK,IACDE,GAAM,GAAIC,SAEZC,OAAS,WACPH,GAAIA,EAAGC,MAGTF,IAAMA,GAId,QAAgBK,GAAkBd,SAC5BA,GAAGe,aAAa,iBACXf,EAAGgB,aAAa,iBACY,MAA1BhB,EAAGiB,WAAWC,QAChBlB,EAAGiB,WAAWD,aAAa,QAE3B,KAIX,QAAgBG,GAASnB,EAAIoB,EAAQC,KACxBD,MAEPE,GAAItB,EAAGuB,MACPC,SAEC,GAAIC,KAAOL,GACVC,MACOI,GAAOH,EAAEG,IAAQ,MAG1BA,GAAOL,EAAOK,SAGXD,GAGT,QAAgBE,GAAQC,EAAOC,GACbC,OAAOC,oBAAoBD,OAAOE,eAAeJ,IACzDK,QAAQ,SAAiBC,KACzBA,GAAUN,EAAMM,GAAQC,KAAKN,KAQvC,QAASO,GAAWf,MACVgB,GAAkCC,EAAlCD,eAAgBE,EAAkBD,EAAlBC,iBAEpBlB,EAAO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AElBvD,GAASH,KAAKG,OAAOtG,EAEvBmG,MAAK/F,QAAQyL,mBACVzL,QAAQyL,aAAavF,QAGvBI,UAAW,OACXJ,OAAOsB,KAAK7D,EAAGC,EAAGkF,YAOhB5C,EAAQR,EALG,QAAZgG,OACGxF,EAAQR,EAAegG,GAAW,GACrCpL,GAAIA,EAAG4F,KAKNH,mCAaJpC,EAAGC,MAAGkF,0DAAa/C,KAAK/F,QAAQ8I,WAAYxI,yDAAKyF,KAAK/F,QAAQ2L,UAC5D5F,KAAKM,QAASN,KAAK0D,WAEnBnD,UAAW,OACXG,KAAKtF,MAAMgE,OAASA,EAAOsC,UAC3BvB,OAAOuB,KAAK9D,EAAGC,EAAGkF,MAEjB5C,GAASH,KAAKG,OAAOtG,YAOpBsG,EAAQR,EALG,QAAZkG,OACG1F,EAAQR,EAAekG,GAAW,GACrCtL,GAAIA,EAAG4F,KAKNH,mDAUDzF,yDAAKyF,KAAK/F,QAAQ6L,aACnB9F,KAAKM,QAASN,KAAK0D,SAElBvD,GAASH,KAAKG,OAAOtG,EAEvBmG,MAAK/F,QAAQ8L,sBACV9L,QAAQ8L,gBAAgB5F,QAG1BuD,MAAO,OACPhD,KAAKtF,MAAMgE,OAASA,EAAO8F,aAC3B/E,OAAO6F,4BAUL7F,EAAQR,EARM,QAAfsG,OACG9F,EAAQR,EAAesG,GAAc,KACvCvC,MAAO,IACPnD,UAAW,EAEZhG,GAAIA,EAAG4F,KAKNH,qBGjRXpG,GAAO8E,SAAU,mBAAoB,cAC/B6E"} \ No newline at end of file diff --git a/src/modules/target.js b/src/modules/target.js index ba6adbfd..59d257ef 100644 --- a/src/modules/target.js +++ b/src/modules/target.js @@ -1,5 +1,9 @@ import { cursor, setStyle, getOriginalSource, transformCssProp } from '../utils' +// Translate z-axis to fix CSS grid display issue in Chrome: +// https://github.com/kingdido999/zooming/issues/42 +const TRANSLATE_Z = 0 + export default { init(el, instance) { this.el = el @@ -30,7 +34,7 @@ export default { transition: `${transformCssProp} ${options.transitionDuration}s ${options.transitionTimingFunction}`, - transform: `translate(${this.translate.x}px, ${this.translate.y}px) + transform: `translate3d(${this.translate.x}px, ${this.translate.y}px, ${TRANSLATE_Z}px) scale(${this.scale.x},${this.scale.y})`, height: `${this.rect.height}px`, width: `${this.rect.width}px` @@ -56,8 +60,8 @@ export default { setStyle(this.el, { cursor: cursor.move, - transform: `translate( - ${this.translate.x + dx}px, ${this.translate.y + dy}px) + transform: `translate3d( + ${this.translate.x + dx}px, ${this.translate.y + dy}px, ${TRANSLATE_Z}px) scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})` }) }, @@ -68,8 +72,8 @@ export default { setStyle(this.el, { transition: transformCssProp, - transform: `translate( - ${this.translate.x + dx}px, ${this.translate.y + dy}px) + transform: `translate3d( + ${this.translate.x + dx}px, ${this.translate.y + dy}px, ${TRANSLATE_Z}px) scale(${this.scale.x + scaleExtra},${this.scale.y + scaleExtra})` }) }, diff --git a/test.html b/test.html index 4faeacbf..6e16e17b 100644 --- a/test.html +++ b/test.html @@ -57,13 +57,13 @@

Image zoom that makes sense.

-

Options below were designed to affect the second image only.

+

+ Options below were designed to affect the second image only. +

faster @@ -76,10 +76,9 @@

Image zoom that makes sense.


- Faced with rolling sand dunes, age-old ruins, caves and howling winds, - your passage will not be an easy one. The goal is to get to the mountaintop, - but the experience is discovering who you are, what this place is, - and what is your purpose. + Faced with rolling sand dunes, age-old ruins, caves and howling winds, your passage will not be an easy one. The + goal is to get to the mountaintop, but the experience is discovering who you are, what this place is, and what + is your purpose.