mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
initial commit
This commit is contained in:
@ -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) {
|
||||||
|
13
ui/scroll-view/scroll-view.d.ts
vendored
13
ui/scroll-view/scroll-view.d.ts
vendored
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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 {
|
||||||
|
Reference in New Issue
Block a user