Changeset 13742
- Timestamp:
- 05/22/2024 03:35:22 PM (2 months ago)
- Location:
- sites/trunk/wp-themes.com/public_html/wp-content/plugins/pattern-page
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wp-themes.com/public_html/wp-content/plugins/pattern-page/build/index.asset.php
r12419 r13742 1 <?php return array('dependencies' => array(), 'version' => ' 9ace78423de40a3ac234');1 <?php return array('dependencies' => array(), 'version' => ''); -
sites/trunk/wp-themes.com/public_html/wp-content/plugins/pattern-page/build/index.js
r12419 r13742 1 (()=>{const e=t=>{for(var n=0;n<t.length;n++){var l=t[n];l.style.visibility="visible",l.children.length>0&&e(l.children)}};window.addEventListener("load",(()=>{var t=document.getElementById("wporg-pattern-preview");t&&(e(t.children),(e=>{let t=e;for(;t.parentElement;)t.parentElement.style.display="block",t=t.parentElement})(t),(e=>{const{top:t,height:n}=e.getBoundingClientRect();e.style.transform=`translate(0, -${t}px)`,n<window.innerHeight&&(e.style.height="100vh")})(t))}))})();1 ); -
sites/trunk/wp-themes.com/public_html/wp-content/plugins/pattern-page/css/style.css
r12349 r13742 1 * { 2 visibility: hidden; 1 /* Hide everything outside of the pattern container */ 2 :not(#wporg-pattern-preview *) { 3 display: none; 3 4 } 4 5 -
sites/trunk/wp-themes.com/public_html/wp-content/plugins/pattern-page/js/index.js
r12419 r13742 1 /**2 * Loops through children of container and set visiblity to 'visible'.3 */4 const makeVisible = ( children ) => {5 for ( var i = 0; i < children.length; i++ ){6 var child = children[i];7 child.style.visibility = 'visible';8 9 if( child.children.length > 0 ) {10 makeVisible( child.children );11 }12 }13 }14 15 /**16 * Move the pattern to the top of the page.17 */18 const adjustOffset = ( element ) => {19 const { top, height } = element.getBoundingClientRect();20 element.style.transform = `translate(0, -${ top }px)`;21 22 // If the element is smaller than the window width, we'll center it23 if( height < window.innerHeight ) {24 element.style.height = '100vh';25 }26 }27 28 1 /** 29 2 * Since we are using a theme template, but hiding everything but 'wporg-pattern-preview', 30 3 * we should erase layouts that could stop our element from displaying full width. 31 4 * If we don't, we get previews that only take up half of the viewport. 32 * 5 * 33 6 */ 34 7 const setParentDisplay = ( element ) => { … … 37 10 while( currElement.parentElement ){ 38 11 currElement.parentElement.style.display = 'block'; 12 13 39 14 40 15 currElement = currElement.parentElement; … … 43 18 44 19 /** 45 * We set all elements to visibility: hidden in CSS and then turn visibility on for our pattern container. 46 * This allows us to preview the page without any distractions, like header, footer, etc... 20 * All elements outside of the preview container are hidden (with CSS, display: none), 21 * to display just the pattern, so only the parent elements of the container 22 * need to be unhidden. 47 23 */ 48 24 const init = () => { 49 25 var container = document.getElementById( 'wporg-pattern-preview' ); 50 26 51 if ( ! container ) {27 if( ! container ) { 52 28 return; 53 29 } 54 30 55 makeVisible( container.children );56 31 setParentDisplay( container ); 57 adjustOffset( container );58 32 } 59 33
Note: See TracChangeset
for help on using the changeset viewer.