diff --git a/example/index.html b/example/index.html index 72cfb43..56a4be9 100644 --- a/example/index.html +++ b/example/index.html @@ -26,6 +26,7 @@

Muban Transition Component

Scroll Transition

+

Looping Animation

@@ -47,6 +48,7 @@

Regular Transition

Scroll Transition

+

Looping Animation

@@ -70,6 +72,7 @@

Regular Transition

Scroll Transition

+

Looping Animation

@@ -93,6 +96,7 @@

Regular Transition

Scroll Transition

+

Looping Animation

@@ -116,6 +120,7 @@

Regular Transition

Scroll Transition

+

Looping Animation

@@ -139,6 +144,7 @@

Regular Transition

Scroll Transition

+

Looping Animation

diff --git a/example/src/component/DummyFooPopup/DummyFooPopupTransitionController.ts b/example/src/component/DummyFooPopup/DummyFooPopupTransitionController.ts index 17ae235..fc3a12c 100644 --- a/example/src/component/DummyFooPopup/DummyFooPopupTransitionController.ts +++ b/example/src/component/DummyFooPopup/DummyFooPopupTransitionController.ts @@ -2,7 +2,7 @@ import MubanTransitionController from '../../../../src/lib/util/MubanTransitionC import { Expo, Back, TimelineMax } from 'gsap'; import DummyFooPopup from './DummyFooPopup'; -class DummyFooPopupTransitionController extends MubanTransitionController { +class DummyFooPopupTransitionController extends MubanTransitionController { /** * @public * @method setupTransitionInTimeline diff --git a/example/src/component/block/DummyFoo/DummyFooTransitionController.ts b/example/src/component/block/DummyFoo/DummyFooTransitionController.ts index 5c9895d..458feb3 100644 --- a/example/src/component/block/DummyFoo/DummyFooTransitionController.ts +++ b/example/src/component/block/DummyFoo/DummyFooTransitionController.ts @@ -2,8 +2,10 @@ import MubanTransitionController from '../../../../../src/lib/util/MubanTransiti import { Expo, TimelineMax } from 'gsap'; import TransitionDirection from 'transition-controller/lib/enum/TransitionDirection'; import DummyFoo from './DummyFoo'; +import getComponentForElement from 'muban-core/lib/utils/getComponentForElement'; +import PrimaryButton from '../../button/PrimaryButton/PrimaryButton'; -class DummyFooTransitionController extends MubanTransitionController { +class DummyFooTransitionController extends MubanTransitionController { /** * Use this method to setup your transition in timeline @@ -21,7 +23,6 @@ class DummyFooTransitionController extends MubanTransitionController { parent.test(); const textContent:HTMLElement = parent.getElement('.js-text-content'); - const primaryButton:HTMLElement = parent.getElement('.js-button-open'); const loopingTitle:HTMLElement = parent.getElement('.js-looping-title'); const loopingAnimation:HTMLElement = parent.getElement('.js-loop-animation'); @@ -31,7 +32,10 @@ class DummyFooTransitionController extends MubanTransitionController { timeline.from(textContent, 0.8, {opacity: 0}, 'afterBg'); timeline.from(textContent, 0.8, {y: 30, ease: Expo.easeOut, clearProps: 'all'}, 'afterBg'); - timeline.add(this.getTimeline(primaryButton, TransitionDirection.IN), 'afterBg+=0.2'); + const component = getComponentForElement(parent.getElement('.js-button-open')); + + timeline.add(this.getTimeline(component, TransitionDirection.IN), 'afterBg+=0.2'); + timeline.add(this.getTimeline(parent.getElement('.js-button-open-2'), TransitionDirection.IN), 'afterBg+=0.2'); timeline.from(loopingTitle, 0.8, {opacity: 0}, 'afterBg+=0.4'); timeline.from(loopingTitle, 0.8, {y: 20, ease: Expo.easeOut}, 'afterBg+=0.4'); diff --git a/example/src/component/button/PrimaryButton/PrimaryButtonTransitionController.ts b/example/src/component/button/PrimaryButton/PrimaryButtonTransitionController.ts index 2870b02..9c0a6f9 100644 --- a/example/src/component/button/PrimaryButton/PrimaryButtonTransitionController.ts +++ b/example/src/component/button/PrimaryButton/PrimaryButtonTransitionController.ts @@ -2,7 +2,7 @@ import MubanTransitionController from '../../../../../src/lib/util/MubanTransiti import { Expo, TimelineMax } from 'gsap'; import PrimaryButton from './PrimaryButton'; -class PrimaryButtonTransitionController extends MubanTransitionController { +class PrimaryButtonTransitionController extends MubanTransitionController { /** * Use this method to setup your transition in timeline * diff --git a/src/lib/util/MubanTransitionController.ts b/src/lib/util/MubanTransitionController.ts index bd91132..aae8673 100644 --- a/src/lib/util/MubanTransitionController.ts +++ b/src/lib/util/MubanTransitionController.ts @@ -4,9 +4,9 @@ import isElement from 'lodash/isElement'; import isString from 'lodash/isString'; import { IMubanTransitionMixin } from '../interface/IMubanTransitionMixin'; -export default abstract class MubanTransitionController< - T extends IMubanTransitionMixin -> extends AbstractTransitionController { +export default abstract class MubanTransitionController extends AbstractTransitionController< + IMubanTransitionMixin +> { /** * This method finds a component based on a string, a html element or the instance. * @@ -14,15 +14,19 @@ export default abstract class MubanTransitionController< * @param {string | HTMLElement | IMubanTransitionMixin} component * @returns {IMubanTransitionMixin} */ - protected getComponent(component: string | HTMLElement | T): T { - let instance: T; + protected getComponent( + component: string | HTMLElement | IMubanTransitionMixin, + ): IMubanTransitionMixin { + let instance: IMubanTransitionMixin; if (isElement(component)) { - instance = getComponentForElement(component); + instance = getComponentForElement(component); } else if (isString(component)) { - instance = getComponentForElement(this.parentController.getElement(component)); + instance = getComponentForElement( + this.parentController.getElement(component), + ); } else { - instance = component; + instance = component; } if (instance === undefined) { diff --git a/tool/convert.js b/tool/convert.js index ef40f91..4297928 100644 --- a/tool/convert.js +++ b/tool/convert.js @@ -6,7 +6,7 @@ const actions = [ { type: actionType.RUN, label: 'Update the seng-generator template path.', - command: 'sg settings -t ./build-tools/template,./node_modules/muban-transition-component/template', + command: 'sg settings -t ./build-tools/generator-template,./node_modules/muban-transition-component/template', }, { type: actionType.REPLACE, @@ -16,7 +16,6 @@ const actions = [ } ]; - confirm('Running this script will replace/adapt files, are you running this on a clean project?', function (ok) { if (ok) { sequentialPromises(parseActions(actions))