Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	yarn.lock
  • Loading branch information
riccoarntz committed May 16, 2019
2 parents 224eff7 + 6a41e07 commit c6f4edb
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 72 deletions.
59 changes: 34 additions & 25 deletions example/bundle.js

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ <h1 class="site-header-title">Muban <span>Transition Component</span></h1>
class="dummy-foo"
data-scroll-component>

<span class="dummy-foo-bg abs-fill js-background"></span>
<span class="dummy-foo-bg abs-fill js-background">
<div class="progress js-progress"></div>
</span>

<div class="abs-center js-text-content">
<h1 class="heading-01">Scroll Transition</h1>
Expand All @@ -42,7 +44,9 @@ <h2 class="heading-02 abs-center js-title">Regular Transition</h2>
data-component="dummy-foo"
class="dummy-foo"
data-scroll-component>
<span class="dummy-foo-bg abs-fill js-background"></span>
<span class="dummy-foo-bg abs-fill js-background">
<div class="progress js-progress"></div>
</span>

<div class="abs-center js-text-content">
<h1 class="heading-01">Scroll Transition</h1>
Expand All @@ -66,7 +70,9 @@ <h2 class="heading-02 abs-center js-title">Regular Transition</h2>
data-component="dummy-foo"
class="dummy-foo"
data-scroll-component>
<span class="dummy-foo-bg abs-fill js-background"></span>
<span class="dummy-foo-bg abs-fill js-background">
<div class="progress js-progress"></div>
</span>

<div class="abs-center js-text-content">
<h1 class="heading-01">Scroll Transition</h1>
Expand All @@ -90,7 +96,9 @@ <h2 class="heading-02 abs-center js-title">Regular Transition</h2>
data-component="dummy-foo"
class="dummy-foo"
data-scroll-component>
<span class="dummy-foo-bg abs-fill js-background"></span>
<span class="dummy-foo-bg abs-fill js-background">
<div class="progress js-progress"></div>
</span>

<div class="abs-center js-text-content">
<h1 class="heading-01">Scroll Transition</h1>
Expand All @@ -114,7 +122,9 @@ <h2 class="heading-02 abs-center js-title">Regular Transition</h2>
data-component="dummy-foo"
class="dummy-foo"
data-scroll-component>
<span class="dummy-foo-bg abs-fill js-background"></span>
<span class="dummy-foo-bg abs-fill js-background">
<div class="progress js-progress"></div>
</span>

<div class="abs-center js-text-content">
<h1 class="heading-01">Scroll Transition</h1>
Expand All @@ -138,7 +148,9 @@ <h2 class="heading-02 abs-center js-title">Regular Transition</h2>
data-component="dummy-foo"
class="dummy-foo"
data-scroll-component>
<span class="dummy-foo-bg abs-fill js-background"></span>
<span class="dummy-foo-bg abs-fill js-background">
<div class="progress js-progress"></div>
</span>

<div class="abs-center js-text-content">
<h1 class="heading-01">Scroll Transition</h1>
Expand Down
22 changes: 16 additions & 6 deletions example/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@ export default class App extends CoreComponent{
static displayName: string = 'app-root';

public scrollTrackerComponentManager: ScrollTrackerComponentManager<IMubanTransitionMixin> = new ScrollTrackerComponentManager<IMubanTransitionMixin>({
config: {
setDebugLabel: true,
debugBorderColor: 'red',
resizeDebounce: 100,
}
inViewProgressEnabled: true,
setDebugLabel: true,
debugBorderColor: 'red',
scrollThrottle: 100,
resizeDebounce: 100,

enableSmoothScroll: true,
smoothScrollOptions: {
damping: 0.1,
thumbMinSize: 20,
renderByPixels: true,
alwaysShowTracks: false,
continuousScrolling: true,
wheelEventTarget: null,
plugins: {},
},
});

constructor(element: HTMLElement) {
Expand All @@ -36,7 +47,6 @@ export default class App extends CoreComponent{
// clean up stuff when hot reloading
if (this.scrollTrackerComponentManager) {
this.scrollTrackerComponentManager.dispose();
this.scrollTrackerComponentManager = null;
}
}
}
24 changes: 17 additions & 7 deletions example/src/component/block/DummyFoo/DummyFoo.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import CoreComponent from 'muban-core/lib/CoreComponent';
import getComponentForElement from 'muban-core/lib/utils/getComponentForElement';
import DummyFooPopup from '../../DummyFooPopup/DummyFooPopup';
// import getComponentForElement from 'muban-core/lib/utils/getComponentForElement';
// import DummyFooPopup from '../../DummyFooPopup/DummyFooPopup';
import DummyFooTransitionController from './DummyFooTransitionController';
import mubanTransitionMixin from '../../../../../src/lib/mixin/MubanTransitionMixin';
import mubanTransitionCoreMixin from '../../../../../src/lib/mixin/MubanTransitionCoreMixin';

export default class DummyFoo extends mubanTransitionMixin(mubanTransitionCoreMixin(CoreComponent)) {
static displayName: string = 'dummy-foo';
public transitionController: DummyFooTransitionController;
// public transitionController: DummyFooTransitionController;

private dummyFooPopup: DummyFoo;
// private dummyFooPopup: DummyFoo;

constructor(public element: HTMLElement) {
super(element);

this.transitionController = new DummyFooTransitionController(this);
this.addEventListeners();
this.dummyFooPopup = getComponentForElement(this.element.querySelector(`[data-component="${DummyFooPopup.displayName}"]`));
// this.dummyFooPopup = getComponentForElement(this.element.querySelector(`[data-component="${DummyFooPopup.displayName}"]`));
}

/**
* @public
* @method inViewProgress
*/
public inViewProgress(progress:number):void
{
(<HTMLElement>this.element.querySelector('.js-progress')).style.width = `${progress * 100}%`;

console.log(progress);
}

/**
Expand All @@ -28,7 +39,6 @@ export default class DummyFoo extends mubanTransitionMixin(mubanTransitionCoreMi

}


/**
* @private
* @method addEventListeners
Expand All @@ -42,7 +52,7 @@ export default class DummyFoo extends mubanTransitionMixin(mubanTransitionCoreMi
* @method handleOpenPopupClick
*/
private handleOpenPopupClick(): void {
this.dummyFooPopup.transitionIn();
// this.dummyFooPopup.transitionIn();
}

public dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DummyFooTransitionController extends MubanTransitionController {
*/
protected setupTransitionInTimeline(
timeline:TimelineMax,
parent:DummyFoo
parent:any
): void {
parent.test();

Expand Down
12 changes: 11 additions & 1 deletion example/src/style/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ body {
margin: 0;
color: #6c757d;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;
height: 100%;
}

h1,h2,h3,h4 {
Expand Down Expand Up @@ -97,6 +98,14 @@ h1,h2,h3,h4 {
position: relative;
}

.progress {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
background-color: blue;
}

.site-header {
position: fixed;
Expand Down Expand Up @@ -128,6 +137,7 @@ h1,h2,h3,h4 {
text-align: center;
white-space: nowrap;
color: #41a6ff;
border-bottom: 1px dotted white;
}

.dummy-foo-bg {
Expand All @@ -139,7 +149,7 @@ h1,h2,h3,h4 {
}

.dummy-foo:nth-child(n+2) .dummy-foo-bg {
background-color: white;
/*background-color: white;*/
}

/* Dummy Foo POPUP */
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"eslint-import-resolver-typescript": "^1.0.2",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-prettier": "^2.4.0",
"gsap": "^2.1.2",
"gsap": "^2.0.1",
"husky": "^0.14.3",
"jsdom": "^11.5.1",
"jsdom-global": "^3.0.2",
Expand All @@ -110,10 +110,10 @@
"lodash": "^4.17.5",
"muban-core": "^1.8.3",
"node-run-cmd": "^1.0.1",
"scroll-tracker-component-manager": "^1.1.1",
"scroll-tracker-component-manager": "^2.1.1",
"seng-disposable": "^1.1.3",
"seng-event": "^1.2.3",
"transition-controller": "^1.2.12"
"transition-controller": "^1.3.1"
},
"peerDependencies": {
"gsap": "^2.0.1"
Expand Down
22 changes: 22 additions & 0 deletions src/lib/interface/IMubanTransitionMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export interface IMubanTransitionMixin extends IMubanTransitionCoreMixin {
* it's not transitioned in it will still try to transitionIn */
beyondView(): void;

/**
* @public
* @method inViewProgress
* @description triggered every time the scroll-position changes and your component is within the viewport. This method will have the parameter progress which is a number between 0-1.
*/
inViewProgress(progress: number): void;

/**
* Calling transition in will trigger transitionIn on your transition controller and
* start the desired timeline.
Expand Down Expand Up @@ -75,4 +82,19 @@ export interface IMubanTransitionMixin extends IMubanTransitionCoreMixin {
* Setting this number to for example 0.5 will trigger the enterView method when the component is already visible for 50% within your viewport.
*/
enterViewThreshold: number;

/**
* @description: same as enterViewThreshold but then used as an offset from when your inViewProgress will start
*/
inViewProgressThreshold: number;

/**
* @description: PropertyName of the component that should is by default set to false. Will be set to value if it has passed the viewport once already
*/
hasEntered: boolean;

/**
* @description: PropertyName of the component where we will store the progress of its visibility
*/
currentViewProgress: number;
}
5 changes: 5 additions & 0 deletions src/lib/mixin/MubanTransitionMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function mubanTransitionMixin<TBase extends Constructor<IMubanTransitionCoreMixi
return class MubanTransitionMixin extends Base {
public transitionController: AbstractTransitionController<IMubanTransitionMixin>;
public enterViewThreshold: number = 0.25;
public inViewProgressThreshold: number = 0;
public hasEntered: boolean = false;
public currentViewProgress: number = 0;

constructor(...args: any[]) {
super(...args);
Expand All @@ -24,6 +26,9 @@ function mubanTransitionMixin<TBase extends Constructor<IMubanTransitionCoreMixi
this.stopLoopingAnimation();
}

// @ts-ignore
public inViewProgress(progress: number): void {}

public beyondView(): void {
if (!this.hasEntered) {
// Todo maybe seek to progress(1) to avoid (unnecessary) performance issue's
Expand Down
6 changes: 6 additions & 0 deletions test/MubanTransitionMixin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ describe('MubanTransitionMixin.spec', () => {
});
});

describe('inViewProgress', function () {
it('should inViewProgress the component', function () {
expect(component.inViewProgress()).to.be.undefined;
});
});

describe('leaveView', function () {
it('should leaveView the component', function () {
expect(component.leaveView()).to.be.undefined;
Expand Down
10 changes: 4 additions & 6 deletions test/util/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import AppTransitionController from './AppTransitionController';
import mubanTransitionCoreMixin from '../../src/lib/mixin/MubanTransitionCoreMixin';
import mubanTransitionMixin from '../../src/lib/mixin/MubanTransitionMixin';

export default class App extends mubanTransitionMixin(mubanTransitionCoreMixin(CoreComponent)){
export default class App extends mubanTransitionMixin(mubanTransitionCoreMixin(CoreComponent)) {
static displayName: string = 'app-root';
public transitionController: AppTransitionController;

public scrollTrackerComponentManager: ScrollTrackerComponentManager<IMubanTransitionMixin> = new ScrollTrackerComponentManager<IMubanTransitionMixin>({
config: {
setDebugLabel: true,
debugBorderColor: 'red',
resizeDebounce: 100,
}
setDebugLabel: true,
debugBorderColor: 'red',
resizeDebounce: 100,
});

constructor(element: HTMLElement) {
Expand Down
22 changes: 16 additions & 6 deletions tool/convert/src/app/component/layout/app/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ export default class App extends AbstractComponent {
static displayName: string = 'app-root';

public scrollTrackerComponentManager: ScrollTrackerComponentManager<IMubanTransitionMixin> = new ScrollTrackerComponentManager<IMubanTransitionMixin>({
config: {
setDebugLabel: true,
debugBorderColor: 'red',
resizeDebounce: 100,
}
inViewProgressEnabled: false,
setDebugLabel: true,
debugBorderColor: 'red',
scrollThrottle: 100,
resizeDebounce: 100,

enableSmoothScroll: false,
smoothScrollOptions: {
damping: 0.1,
thumbMinSize: 20,
renderByPixels: true,
alwaysShowTracks: false,
continuousScrolling: true,
wheelEventTarget: null,
plugins: {},
},
});

constructor(element: HTMLElement) {
Expand All @@ -31,7 +42,6 @@ export default class App extends AbstractComponent {
// clean up stuff when hot reloading
if (this.scrollTrackerComponentManager) {
this.scrollTrackerComponentManager.dispose();
this.scrollTrackerComponentManager = null;
}
}
}
Loading

0 comments on commit c6f4edb

Please sign in to comment.