UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

96 lines (90 loc) 2.64 kB
import BaseComponent from '@primevue/core/basecomponent'; import ImageCompareStyle from 'primevue/imagecompare/style'; import { openBlock, createElementBlock, mergeProps, renderSlot, createElementVNode } from 'vue'; var script$1 = { name: 'BaseImageCompare', "extends": BaseComponent, props: { tabindex: { type: Number, "default": 0 }, ariaLabelledby: { type: String, "default": null }, ariaLabel: { type: String, "default": null } }, style: ImageCompareStyle, provide: function provide() { return { $pcImageCompare: this, $parentInstance: this }; } }; var script = { name: 'ImageCompare', "extends": script$1, mutationObserver: null, data: function data() { return { isRTL: false }; }, beforeUnmount: function beforeUnmount() { if (this.mutationObserver) { this.mutationObserver.disconnect(); } }, mounted: function mounted() { this.updateDirection(); this.observeDirectionChanges(); }, methods: { onSlide: function onSlide(event) { var value = event.target.value; var image = event.target.previousElementSibling; if (this.isRTL) { image.style.clipPath = "polygon(".concat(100 - value, "% 0, 100% 0, 100% 100%, ").concat(100 - value, "% 100%)"); } else { image.style.clipPath = "polygon(0 0, ".concat(value, "% 0, ").concat(value, "% 100%, 0 100%)"); } }, updateDirection: function updateDirection() { this.isRTL = !!this.$el.closest('[dir="rtl"]'); }, observeDirectionChanges: function observeDirectionChanges() { var _this = this; var targetNode = document.documentElement; var config = { attributes: true, attributeFilter: ['dir'] }; this.mutationObserver = new MutationObserver(function () { _this.updateDirection(); }); this.mutationObserver.observe(targetNode, config); } } }; function render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", mergeProps({ "class": _ctx.cx('root') }, _ctx.ptmi('root')), [renderSlot(_ctx.$slots, "left"), renderSlot(_ctx.$slots, "right"), createElementVNode("input", mergeProps({ type: "range", min: "0", max: "100", value: "50", onInput: _cache[0] || (_cache[0] = function () { return $options.onSlide && $options.onSlide.apply($options, arguments); }), "class": _ctx.cx('slider') }, _ctx.ptm('slider')), null, 16)], 16); } script.render = render; export { script as default }; //# sourceMappingURL=index.mjs.map