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KAAK,SAAS,WAC1B,sBAAuB,KAAK,SAAS,sBACrC,cAAe,KAAK,SAAS,cAC7B,OAAQ,KAAK,SAAS,WACtB,UAAW,KAAK,SAAS,UACzB,cAAe,KAAK,SAAS,cAC7B,cAAe,KAAK,SAAS,cAC7B,gBAAiB,KAAK,SAAS,iBAEnC,CAEA,aAAA,GACE,KAAK,QAAU,IAAI,QAAQ,CACzB,GAAI,KAAK,UACT,SAAU,KAAK,SACf,YAAa,KAAK,SAAS,YAC3B,OAAQ,KAAK,SAAS,OACtB,OAAQ,KAAK,SAAS,OACtB,gBAAiB,KAAK,SAAS,gBAC/B,WAAY,KAAK,SAAS,WAC1B,WAAY,KAAK,SAAS,WAC1B,iBAAkB,KAAK,SAAS,iBAChC,iBAAkB,KAAK,SAAS,iBAChC,UAAW,KAAK,SAAS,UACzB,WAAY,KAAK,SAAS,YAE9B,CAEA,eAAA,CAAgB,GACd,KAAK,SAAS,aAAa,EAC7B,CAEA,OAAA,GACE,KAAK,QAAQ,SAAU,CACzB,CAEA,MAAA,GACE,KAAK,QAAQ,SAAU,CACzB,CAEA,QAAU,KACR,KAAK,QAAQ,eAAe","file":"/npm/cosium-drift-zoom@1.0.2/src/js/Drift.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cosium-drift-zoom@1.0.2/src/js/Drift.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { isDOMElement } from './util/dom';\nimport injectBaseStylesheet from './injectBaseStylesheet';\n\nimport Trigger from './Trigger';\nimport ZoomPane from './ZoomPane';\n\nmodule.exports = class Drift {\n  VERSION = '1.0.0'\n\n  constructor(triggerEl, options = {}) {\n    this.triggerEl = triggerEl;\n\n    if (!isDOMElement(this.triggerEl)) {\n      throw new TypeError('`new Drift` requires a DOM element as its first argument.');\n    }\n\n    // A bit unexpected if you haven't seen this pattern before.\n    // Based on the pattern here:\n    // https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20&%20beyond/ch2.md#nested-defaults-destructured-and-restructured\n    let {\n      // Prefix for generated element class names (e.g. `my-ns` will\n      // result in classes such as `my-ns-pane`. Default `drift-`\n      // prefixed classes will always be added as well.\n      namespace = null,\n      // Whether the ZoomPane should show whitespace when near the edges.\n      showWhitespaceAtEdges = false,\n      // Whether the inline ZoomPane should stay inside\n      // the bounds of its image.\n      containInline = false,\n      // How much to offset the ZoomPane from the\n      // interaction point when inline.\n      inlineOffsetX = 0,\n      inlineOffsetY = 0,\n      // A DOM element to append the inline ZoomPane to\n      inlineContainer = document.body,\n      // Which trigger attribute to pull the ZoomPane image source from.\n      sourceAttribute = 'data-zoom',\n      // How much to magnify the trigger by in the ZoomPane.\n      // (e.g., `zoomFactor = 3` will result in a 900 px wide ZoomPane image\n      // if the trigger is displayed at 300 px wide)\n      zoomFactor = 3,\n      // A DOM element to append the non-inline ZoomPane to.\n      // Required if `inlinePane !== true`.\n      paneContainer = document.body,\n      // When to switch to an inline ZoomPane. This can be a boolean or\n      // an integer. If `true`, the ZoomPane will always be inline,\n      // if `false`, it will switch to inline when `windowWidth <= inlinePane`\n      inlinePane = 375,\n      // If `true`, touch events will trigger the zoom, like mouse events.\n      handleTouch = true,\n      // If present (and a function), this will be called\n      // whenever the ZoomPane is shown.\n      onShow = null,\n      // If present (and a function), this will be called\n      // whenever the ZoomPane is hidden.\n      onHide = null,\n      // Add base styles to the page. See the \"Theming\"\n      // section of README.md for more information.\n      injectBaseStyles = true,\n      // An optional number that determines how long to wait before\n      // showing the ZoomPane because of a `mouseenter` event.\n      hoverDelay = 0,\n      // An optional number that determines how long to wait before\n      // showing the ZoomPane because of a `touchstart` event.\n      // It's unlikely that you would want to use this option, since\n      // \"tap and hold\" is much more intentional than a hover event.\n      touchDelay = 0,\n      // If true, a bounding box will show the area currently being previewed\n      // during mouse hover\n      hoverBoundingBox = false,\n      // If true, a bounding box will show the area currently being previewed\n      // during touch events\n      touchBoundingBox = false,\n    } = options;\n\n    if (inlinePane !== true && !isDOMElement(paneContainer)) {\n      throw new TypeError('`paneContainer` must be a DOM element when `inlinePane !== true`');\n    }\n    if(!isDOMElement(inlineContainer)){\n      throw new TypeError('`inlineContainer` must be a DOM element');\n    }\n\n    this.settings = { namespace, showWhitespaceAtEdges, containInline, inlineOffsetX, inlineOffsetY, inlineContainer, sourceAttribute, zoomFactor, paneContainer, inlinePane, handleTouch, onShow, onHide, injectBaseStyles, hoverDelay, touchDelay, hoverBoundingBox, touchBoundingBox };\n\n    if (this.settings.injectBaseStyles) {\n      injectBaseStylesheet();\n    }\n\n    this._buildZoomPane();\n    this._buildTrigger();\n  }\n\n  get isShowing() {\n    return this.zoomPane.isShowing;\n  }\n\n  get zoomFactor() {\n    return this.settings.zoomFactor;\n  }\n\n  set zoomFactor(zf) {\n    this.settings.zoomFactor = zf;\n    this.zoomPane.settings.zoomFactor = zf;\n  }\n\n  _buildZoomPane() {\n    this.zoomPane = new ZoomPane({\n      container: this.settings.paneContainer,\n      zoomFactor: this.settings.zoomFactor,\n      showWhitespaceAtEdges: this.settings.showWhitespaceAtEdges,\n      containInline: this.settings.containInline,\n      inline: this.settings.inlinePane,\n      namespace: this.settings.namespace,\n      inlineOffsetX: this.settings.inlineOffsetX,\n      inlineOffsetY: this.settings.inlineOffsetY,\n      inlineContainer: this.settings.inlineContainer\n    });\n  }\n\n  _buildTrigger() {\n    this.trigger = new Trigger({\n      el: this.triggerEl,\n      zoomPane: this.zoomPane,\n      handleTouch: this.settings.handleTouch,\n      onShow: this.settings.onShow,\n      onHide: this.settings.onHide,\n      sourceAttribute: this.settings.sourceAttribute,\n      hoverDelay: this.settings.hoverDelay,\n      touchDelay: this.settings.touchDelay,\n      hoverBoundingBox: this.settings.hoverBoundingBox,\n      touchBoundingBox: this.settings.touchBoundingBox,\n      namespace: this.settings.namespace,\n      zoomFactor: this.settings.zoomFactor,\n    });\n  }\n\n  setZoomImageURL(imageURL) {\n    this.zoomPane._setImageURL(imageURL);\n  };\n\n  disable() {\n    this.trigger.enabled = false;\n  }\n\n  enable() {\n    this.trigger.enabled = true;\n  }\n\n  destroy = () => {\n    this.trigger._unbindEvents();\n  };\n}\n"]}