Skip to content

Commit

Permalink
feat(md-scrollfire): remove scrollfire patch, provide it optionally, c…
Browse files Browse the repository at this point in the history
…loses #161
  • Loading branch information
Thanood committed Apr 6, 2016
1 parent e633eb4 commit d0e68b2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/config-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export class ConfigBuilder {

useGlobalResources: boolean = true;
useScrollfirePatch: boolean = false;
globalResources = [];

useAll(): ConfigBuilder {
Expand Down Expand Up @@ -261,4 +262,9 @@ export class ConfigBuilder {
this.useGlobalResources = false;
return this;
}

withScrollfirePatch(): ConfigBuilder {
this.useScrollfirePatch = true;
return this;
}
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'materialize';
import {ConfigBuilder} from './config-builder';
import {ScrollfirePatch} from './scrollfire/scrollfire-patch';

export function configure(aurelia, configCallback) {
let builder = new ConfigBuilder();
Expand All @@ -11,6 +12,9 @@ export function configure(aurelia, configCallback) {
if (builder.useGlobalResources) {
aurelia.globalResources(builder.globalResources);
}
if (builder.useScrollfirePatch) {
new ScrollfirePatch().patch();
}
}

// build-index-remove start
Expand Down
6 changes: 3 additions & 3 deletions src/scrollfire/scrollfire-patch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint no-new-func:0 */
export class ScrollfirePatch {
patched = false;
static patched = false;

patch() {
if (!this.patched) {
this.patched = true;
if (!ScrollfirePatch.patched) {
ScrollfirePatch.patched = true;

window.Materialize.scrollFire = function(options) {
let didScroll = false;
Expand Down
6 changes: 2 additions & 4 deletions src/scrollfire/scrollfire.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { customAttribute } from 'aurelia-templating';
import { inject } from 'aurelia-dependency-injection';
import { getLogger } from 'aurelia-logging';
import { ScrollfirePatch } from './scrollfire-patch';

@customAttribute('md-scrollfire')
@inject(Element, ScrollfirePatch)
@inject(Element)
export class MdScrollfire {
targetId = 0;
constructor(element, scrollfirePatch) {
scrollfirePatch.patch();
constructor(element) {
this.element = element;
this.log = getLogger('md-scrollfire');
}
Expand Down

0 comments on commit d0e68b2

Please sign in to comment.