@wildebeest/scroll
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -34,2 +34,6 @@ "use strict"; | ||
var height = this.element.offsetHeight; | ||
if (height == 0) { | ||
this.mark.setTop(0); | ||
return; | ||
} | ||
var position = this.mark.getTop(); | ||
@@ -36,0 +40,0 @@ this.mark.setTop(position + value / height * 100); |
@@ -31,3 +31,6 @@ "use strict"; | ||
this.domService.insert(scrollMark.getElement(), scrollBarElement); | ||
return new ScrollBar_1.ScrollBar(scrollBarElement, scrollMark, this.emitterService.createEmitter()); | ||
if (!data.emitter) { | ||
data.emitter = this.emitterService.createEmitter(); | ||
} | ||
return new ScrollBar_1.ScrollBar(scrollBarElement, scrollMark, data.emitter); | ||
}; | ||
@@ -34,0 +37,0 @@ ScrollBarBuilder.prototype.setTemplate = function (template) { |
@@ -1,2 +0,2 @@ | ||
import { DomService, EmitterService } from "@wildebeest/common"; | ||
import { DomService, EmitterService, Emitter } from "@wildebeest/common"; | ||
import { TouchElement } from "@wildebeest/touch"; | ||
@@ -9,10 +9,14 @@ import { ScrollBar } from "./ScrollBar"; | ||
protected emitterService: EmitterService; | ||
protected emitter: Emitter; | ||
protected scrollBar: ScrollBar; | ||
protected touchElement: TouchElement; | ||
protected element: any; | ||
protected pane: any; | ||
protected element: HTMLElement; | ||
protected pane: HTMLElement; | ||
protected config: any; | ||
constructor(domService: DomService, scrollBarBuilder: ScrollBarBuilder, emitterService: EmitterService); | ||
initialize(element: any): void; | ||
scrollTo(interpolatePercentage: number): void; | ||
initialize(element: HTMLElement, config?: any): void; | ||
protected scrollTo(interpolatePercentage: number): void; | ||
recalc(): void; | ||
getBar(): ScrollBar; | ||
getPane(): HTMLElement; | ||
} |
@@ -24,13 +24,17 @@ "use strict"; | ||
this.emitterService = emitterService; | ||
this.emitter = this.emitterService.createEmitter(); | ||
} | ||
ScrollBox.prototype.initialize = function (element) { | ||
ScrollBox.prototype.initialize = function (element, config) { | ||
var _this = this; | ||
if (config === void 0) { config = {}; } | ||
this.element = element; | ||
this.touchElement = new touch_1.TouchElement(this.element, this.emitterService.createEmitter()); | ||
this.config = config; | ||
this.touchElement = new touch_1.TouchElement(this.element, this.emitter); | ||
this.pane = this.element.firstElementChild; | ||
if (this.element.children.length > 1) { | ||
console.log(this.element.childNodes); | ||
throw "Scroll Box cannot have more then 1 child element"; | ||
} | ||
this.scrollBar = this.scrollBarBuilder.build(); | ||
this.scrollBar = this.scrollBarBuilder.build({ | ||
emitter: this.emitter | ||
}); | ||
this.domService.insert(this.scrollBar.getElement(), this.element); | ||
@@ -60,2 +64,8 @@ this.element.addEventListener('mousewheel', function (event) { | ||
}; | ||
ScrollBox.prototype.getBar = function () { | ||
return this.scrollBar; | ||
}; | ||
ScrollBox.prototype.getPane = function () { | ||
return this.pane; | ||
}; | ||
ScrollBox = __decorate([ | ||
@@ -62,0 +72,0 @@ inversify_1.injectable(), |
@@ -11,3 +11,3 @@ "use strict"; | ||
this.emitter = emitterService.createEmitter(); | ||
var dragable = new drag_1.DragableElement(this.element, emitterService.createEmitter()); | ||
var dragable = new drag_1.DragableElement(this.element, this.emitter); | ||
dragable.getEmitter().on('drag', function (event) { | ||
@@ -14,0 +14,0 @@ _this.emitter.emit('drag', event); |
@@ -16,3 +16,3 @@ "use strict"; | ||
container.bind(ScrollBox_1.ScrollBox).toSelf(); | ||
container.bind('Factory<Builer>').toFactory(function (context) { | ||
container.bind('Factory<Builder>').toFactory(function (context) { | ||
return function (name) { | ||
@@ -19,0 +19,0 @@ return context.container.getNamed('Builder', name); |
{ | ||
"name": "@wildebeest/scroll", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Scroll element with custom scroll bar", | ||
@@ -9,3 +9,4 @@ "main": "dist/index.js", | ||
"build": "tsc --declaration", | ||
"test": "jest" | ||
"test": "jest", | ||
"deploy": "npm run test && npm run build && git add -A && git commit -m 'deploy' && git push origin master" | ||
}, | ||
@@ -18,3 +19,3 @@ "repository": { | ||
"@wildebeest/common": "^0.2.0", | ||
"@wildebeest/drag": "^0.1.1", | ||
"@wildebeest/drag": "^0.2.0", | ||
"@wildebeest/js-modules": "^0.1.0", | ||
@@ -21,0 +22,0 @@ "@wildebeest/touch": "^0.2.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39689
694
+ Added@wildebeest/drag@0.2.0(transitive)
- Removed@wildebeest/drag@0.1.1(transitive)
Updated@wildebeest/drag@^0.2.0