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M,UAAqB;AACzB,yBAAa,mBADY;AAEzB,mBAAO,KAAK,MAFa;AAGzB,mBAAO;AACL,qBAAK,KAAK,GADL;AAEL,qBAAK,KAAK;AAFL,aAHkB;AAOzB,iBAAK;AAPoB,SAA3B;AAUA,YAAM,YAAY,EAAE,KAAF,EAAS;AACzB,yBAAa;AADY,SAAT,EAEf,CACD,EAAE,KAAF,EAAS,OAAT,CADC,CAFe,CAAlB;AAMA,YAAM,UAAU,EAAE,KAAF,EAAS;AACvB,yBAAa;AADU,SAAT,EAEb,KAAK,MAAL,CAAY,OAFC,CAAhB;AAIA,eAAO,EAAE,KAAF,EAAS;AACd,yBAAa,YADC;AAEd,mBAAO;AACL,wBAAW,KAAK,MAAhB;AADK,aAFO;AAKd,gBAAI,KAAK;AALK,SAAT,EAMJ,CAAC,SAAD,EAAY,OAAZ,CANI,CAAP;AAOD;AAxFmF,CAAvE,CAAf","sourcesContent":["// Style\nimport '../../stylus/components/_parallax.styl'\n\n// Mixins\nimport Translatable from '../../mixins/translatable'\n\n// Types\nimport Vue from 'vue'\nimport { VNode, VNodeData } from 'vue/types/vnode'\nimport mixins, { ExtractVue } from '../../util/mixins'\n\ninterface options extends Vue {\n $refs: {\n img: HTMLImageElement\n }\n}\n\n/* @vue/component */\nexport default mixins<options & ExtractVue<typeof Translatable>>(Translatable).extend({\n name: 'v-parallax',\n\n props: {\n alt: {\n type: String,\n default: ''\n },\n height: {\n type: [String, Number],\n default: 500\n },\n src: String\n },\n\n data: () => ({\n isBooted: false\n }),\n\n computed: {\n styles (): object {\n return {\n display: 'block',\n opacity: this.isBooted ? 1 : 0,\n transform: `translate(-50%, ${this.parallax}px)`\n }\n }\n },\n\n watch: {\n parallax () {\n this.isBooted = true\n }\n },\n\n mounted () {\n this.init()\n },\n\n methods: {\n init () {\n const img = this.$refs.img\n\n if (!img) return\n\n if (img.complete) {\n this.translate()\n this.listeners()\n } else {\n img.addEventListener('load', () => {\n this.translate()\n this.listeners()\n }, false)\n }\n },\n objHeight () {\n return this.$refs.img.naturalHeight\n }\n },\n\n render (h): VNode {\n const imgData: VNodeData = {\n staticClass: 'v-parallax__image',\n style: this.styles,\n attrs: {\n src: this.src,\n alt: this.alt\n },\n ref: 'img'\n }\n\n const container = h('div', {\n staticClass: 'v-parallax__image-container'\n }, [\n h('img', imgData)\n ])\n\n const content = h('div', {\n staticClass: 'v-parallax__content'\n }, this.$slots.default)\n\n return h('div', {\n staticClass: 'v-parallax',\n style: {\n height: `${this.height}px`\n },\n on: this.$listeners\n }, [container, content])\n }\n})\n"],"sourceRoot":""}
|