initial commit

This commit is contained in:
Vladimir Enchev
2015-11-09 11:57:32 +02:00
parent ed489585ec
commit c85d2a7afc
3 changed files with 56 additions and 0 deletions

View File

@ -101,6 +101,17 @@ export class ScrollView extends contentView.ContentView implements definition.Sc
} }
this._android.setId(this._androidViewId); this._android.setId(this._androidViewId);
var that = new WeakRef(this);
this._android.getViewTreeObserver().addOnScrollChangedListener(new android.view.ViewTreeObserver.OnScrollChangedListener({
onScrollChanged: function () {
var rootScrollView = that.get();
if (rootScrollView && rootScrollView.android) {
var scrollX = rootScrollView.android.getScrollX(); //for horizontalScrollView
var scrollY = rootScrollView.android.getScrollY(); //for verticalScrollView
}
}
});
} }
public _onOrientationChanged(oldValue: string, newValue: string) { public _onOrientationChanged(oldValue: string, newValue: string) {

View File

@ -46,5 +46,18 @@ declare module "ui/scroll-view" {
* Gets or sets direction in which the content can be scrolled. * Gets or sets direction in which the content can be scrolled.
*/ */
orientation: string; orientation: string;
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any);
/**
* Raised when a tap event occurs.
*/
on(event: "scroll", callback: (args: observable.EventData) => void, thisArg?: any);
} }
} }

View File

@ -7,14 +7,46 @@ import utils = require("utils/utils");
global.moduleMerge(common, exports); global.moduleMerge(common, exports);
class UIScrollViewDelegateImpl extends NSObject implements UIScrollViewDelegate {
public static ObjCProtocols = [UIScrollViewDelegate];
static new(): UIScrollViewDelegateImpl {
return <UIScrollViewDelegateImpl>super.new();
}
private _owner: ScrollView;
public initWithOwner(owner: ScrollView): UIScrollViewDelegateImpl {
this._owner = owner;
return this;
}
public scrollViewDidScroll(textView: UIScrollView): void {
}
}
export class ScrollView extends contentView.ContentView implements definition.ScrollView { export class ScrollView extends contentView.ContentView implements definition.ScrollView {
private _scroll: UIScrollView; private _scroll: UIScrollView;
private _contentMeasuredWidth: number = 0; private _contentMeasuredWidth: number = 0;
private _contentMeasuredHeight: number = 0; private _contentMeasuredHeight: number = 0;
private _delegate: UIScrollViewDelegateImpl;
constructor() { constructor() {
super(); super();
this._scroll = new UIScrollView(); this._scroll = new UIScrollView();
this._delegate = UIScrollViewDelegateImpl.new().initWithOwner(this);
}
public onLoaded() {
super.onLoaded();
this._scroll.delegate = this._delegate;
}
public onUnloaded() {
this._scroll.delegate = null;
super.onUnloaded();
} }
get orientation(): string { get orientation(): string {