-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/TMZ-276' of github.com:elementor/hello-plus int…
…o feature/TMZ-276
- Loading branch information
Showing
23 changed files
with
594 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
$transition: all .3s; | ||
|
||
$corners-shape-default: 8px; | ||
$corners-shape-sharp: 0; | ||
$corners-shape-rounded: 12px; | ||
$corners-shape-round: 32px; | ||
$corners-shape-oval: 50%; | ||
|
||
$corners-image-shape-rounded: 52px; | ||
$corners-image-shape-round: 300px; | ||
|
||
$corners-box-shape-rounded: 52px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
modules/content/assets/js/frontend/handlers/hello-plus-zigzag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
export default class ZigZagHandler extends elementorModules.frontend.handlers.Base { | ||
getDefaultSettings() { | ||
return { | ||
selectors: { | ||
main: '.ehp-zigzag', | ||
itemWrapper: '.ehp-zigzag__item-wrapper', | ||
}, | ||
constants: { | ||
entranceAnimation: 'zigzag_animation', | ||
entranceAnimationAlternate: 'zigzag_animation_alternate', | ||
hasEntranceAnimation: 'has-entrance-animation', | ||
hasAlternateAnimation: 'has-alternate-animation', | ||
none: 'none', | ||
visible: 'visible', | ||
hidden: 'hidden', | ||
}, | ||
}; | ||
} | ||
|
||
getDefaultElements() { | ||
const selectors = this.getSettings( 'selectors' ); | ||
|
||
return { | ||
main: this.$element[ 0 ].querySelector( selectors.main ), | ||
itemWrappers: this.$element[ 0 ].querySelectorAll( selectors.itemWrapper ), | ||
}; | ||
} | ||
|
||
bindEvents() { | ||
if ( this.elements.itemWrappers.length > 0 ) { | ||
this.elements.itemWrappers.forEach( ( itemWrapper ) => { | ||
itemWrapper.addEventListener( 'animationend', this.removeAnimationClasses.bind( this ) ); | ||
} ); | ||
} | ||
} | ||
|
||
getResponsiveSetting( controlName ) { | ||
const currentDevice = elementorFrontend.getCurrentDeviceMode(); | ||
return elementorFrontend.utils.controls.getResponsiveControlValue( this.getElementSettings(), controlName, '', currentDevice ); | ||
} | ||
|
||
initEntranceAnimation() { | ||
const { entranceAnimation, entranceAnimationAlternate, none, visible, hidden } = this.getSettings( 'constants' ); | ||
const entranceAnimationClass = this.getResponsiveSetting( entranceAnimation ); | ||
|
||
if ( ! entranceAnimationClass || none === entranceAnimationClass ) { | ||
return; | ||
} | ||
const alternateAnimationClass = this.getResponsiveSetting( entranceAnimationAlternate ); | ||
|
||
const observerCallback = ( entries ) => { | ||
const sortedEntries = [ ...entries ].sort( ( a, b ) => { | ||
const indexA = a.target.dataset.index; | ||
const indexB = b.target.dataset.index; | ||
return indexA - indexB; | ||
} ); | ||
|
||
sortedEntries.forEach( ( entry, index ) => { | ||
if ( entry.isIntersecting && ! entry.target.classList.contains( visible ) ) { | ||
setTimeout( () => { | ||
entry.target.classList.remove( hidden ); | ||
const entryIndex = parseInt( entry.target.dataset.index, 10 ); | ||
const animation = this.hasAlternateAnimation( entryIndex ) ? alternateAnimationClass : entranceAnimationClass; | ||
entry.target.classList.add( animation ); | ||
}, index * 200 ); | ||
} | ||
} ); | ||
}; | ||
|
||
const observerOptions = { | ||
root: null, | ||
rootMargin: '0px', | ||
threshold: 0.5, | ||
}; | ||
const observer = new IntersectionObserver( observerCallback, observerOptions ); | ||
|
||
this.elements.itemWrappers.forEach( ( element, index ) => { | ||
element.dataset.index = index; | ||
observer.observe( element ); | ||
} ); | ||
} | ||
|
||
removeAnimationClasses( event ) { | ||
const { entranceAnimation, entranceAnimationAlternate, visible, hidden } = this.getSettings( 'constants' ); | ||
const element = event.target; | ||
const entranceAnimationClass = this.getResponsiveSetting( entranceAnimation ); | ||
const alternateAnimationClass = this.getResponsiveSetting( entranceAnimationAlternate ); | ||
const entryIndex = parseInt( element.dataset.index, 10 ); | ||
|
||
const animation = this.hasAlternateAnimation( entryIndex ) ? alternateAnimationClass : entranceAnimationClass; | ||
element.classList.remove( animation ); | ||
|
||
element.classList.remove( hidden ); | ||
element.classList.add( visible ); | ||
} | ||
|
||
hasAlternateAnimation( index ) { | ||
const { hasAlternateAnimation } = this.getSettings( 'constants' ); | ||
const isEven = 0 === ( index + 1 ) % 2; | ||
return this.elements.main.classList.contains( hasAlternateAnimation ) && isEven; | ||
} | ||
|
||
getAlternateAnimationClass( entranceAnimationClass ) { | ||
return entranceAnimationClass.replace( /Right|Left/g, ( match ) => ( 'Right' === match ? 'Left' : 'Right' ) ); | ||
} | ||
|
||
onInit( ...args ) { | ||
const { hasEntranceAnimation } = this.getSettings( 'constants' ); | ||
|
||
super.onInit( ...args ); | ||
|
||
if ( this.elements.main && this.elements.main.classList.contains( hasEntranceAnimation ) ) { | ||
this.initEntranceAnimation(); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
modules/content/assets/js/frontend/hello-plus-zigzag-fe.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default class HelloPlusZigzagFe extends elementorModules.Module { | ||
constructor() { | ||
super(); | ||
|
||
elementorFrontend.elementsHandler.attachHandler( 'zigzag', [ | ||
() => import( /* webpackChunkName: 'js/content' */ './handlers/hello-plus-zigzag' ), | ||
] ); | ||
} | ||
} | ||
|
||
window.addEventListener( 'elementor/frontend/init', () => { | ||
new HelloPlusZigzagFe(); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.