FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
packages
/
blocks-next
/
build
/
scripts
/
sticky-purchase
Edit File: index.js
import*as t from"@wordpress/interactivity";var e,o,n={d:function(t,e){for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},r=(e={getContext:function(){return t.getContext},getElement:function(){return t.getElement},store:function(){return t.store}},o={},n.d(o,e),o);const{state:i}=(0,r.store)("surecart/product-page"),{state:c}=(0,r.store)("surecart/sticky-purchase",{state:{isVisible:!1,stickyButtonElement:()=>document.querySelector(".sc-sticky-purchase"),floatingCartElement:()=>document.querySelector(".wp-block-surecart-cart-icon"),isContentUnavailable(){const t=(0,r.getContext)();return"always"!==t?.showStickyPurchaseButton&&i.isUnavailable}},actions:{toggleVisibility(){if(!c.stickyButtonElement())return;const{ref:t}=(0,r.getElement)();window.scrollY+window.innerHeight>=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)?c.isVisible=!1:c.isVisible=t?.getBoundingClientRect().bottom<0}},callbacks:{updateStickyOffsetVariables(){if(!c.isVisible)return void document.body.style.removeProperty("--sc-cart-icon-bottom");const t=(0,r.getElement)()?.ref;if(!t)return;const e=t.getBoundingClientRect();document.body.style.removeProperty("--sc-cart-icon-bottom");const o=c.floatingCartElement();if(!o||!((t,e)=>{const o=t.getBoundingClientRect(),n=e.getBoundingClientRect();return!(o.right<n.left||o.left>n.right||o.bottom<n.top||o.top>n.bottom)})(t,o))return;const n=window.innerHeight-e.bottom;document.body.style.setProperty("--sc-cart-icon-bottom",`${n+e.height+20}px`)}}});
Save
Back