feat:optimize iOS Transform setting
This commit is contained in:
parent
35e9f05114
commit
0fa121e54f
@ -139,6 +139,7 @@ class MovieVM extends ViewModel<MovieModel, MovieVH>{
|
|||||||
this.updateState(state => state.doubanModel = JSON.parse(ret.data) as DoubanModel)
|
this.updateState(state => state.doubanModel = JSON.parse(ret.data) as DoubanModel)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onBind(state: MovieModel, vh: MovieVH) {
|
onBind(state: MovieModel, vh: MovieVH) {
|
||||||
if (state.doubanModel) {
|
if (state.doubanModel) {
|
||||||
vh.title.text = state.doubanModel.title
|
vh.title.text = state.doubanModel.title
|
||||||
@ -162,7 +163,7 @@ class MovieVM extends ViewModel<MovieModel, MovieVH>{
|
|||||||
}
|
}
|
||||||
v.getLocationOnScreen(context).then(ret => {
|
v.getLocationOnScreen(context).then(ret => {
|
||||||
const centerX = ret.x + v.width / 2;
|
const centerX = ret.x + v.width / 2;
|
||||||
vh.scrolled.scrollBy(context, { x: centerX - Environment.screenWidth / 2, y: 0 })
|
vh.scrolled.scrollBy(context, { x: centerX - Environment.screenWidth / 2, y: 0 }, true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -152,13 +152,15 @@ - (void)transformProperties {
|
|||||||
if (self.rotation) {
|
if (self.rotation) {
|
||||||
transform = CGAffineTransformRotate(transform, (self.rotation.floatValue ?: 0) * M_PI);
|
transform = CGAffineTransformRotate(transform, (self.rotation.floatValue ?: 0) * M_PI);
|
||||||
}
|
}
|
||||||
if (!CGAffineTransformEqualToTransform(transform, self.view.transform)) {
|
|
||||||
self.view.transform = transform;
|
|
||||||
}
|
|
||||||
if (self.pivotX || self.pivotY) {
|
if (self.pivotX || self.pivotY) {
|
||||||
self.view.layer.anchorPoint = CGPointMake(self.pivotX.floatValue
|
self.view.layer.anchorPoint = CGPointMake(self.pivotX.floatValue
|
||||||
?: 0.5f, self.pivotY.floatValue ?: 0.5f);
|
?: 0.5f, self.pivotY.floatValue ?: 0.5f);
|
||||||
}
|
}
|
||||||
|
if (!CGAffineTransformEqualToTransform(transform, self.view.transform)) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
self.view.transform = transform;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop {
|
- (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||||
|
@ -367,6 +367,12 @@ var View = /** @class */ (function () {
|
|||||||
View.prototype.getHeight = function (context) {
|
View.prototype.getHeight = function (context) {
|
||||||
return this.nativeChannel(context, 'getHeight')();
|
return this.nativeChannel(context, 'getHeight')();
|
||||||
};
|
};
|
||||||
|
View.prototype.getX = function (context) {
|
||||||
|
return this.nativeChannel(context, 'getX')();
|
||||||
|
};
|
||||||
|
View.prototype.getY = function (context) {
|
||||||
|
return this.nativeChannel(context, 'getY')();
|
||||||
|
};
|
||||||
View.prototype.getLocationOnScreen = function (context) {
|
View.prototype.getLocationOnScreen = function (context) {
|
||||||
return this.nativeChannel(context, "getLocationOnScreen")();
|
return this.nativeChannel(context, "getLocationOnScreen")();
|
||||||
};
|
};
|
||||||
|
@ -283,6 +283,12 @@ class View {
|
|||||||
getHeight(context) {
|
getHeight(context) {
|
||||||
return this.nativeChannel(context, 'getHeight')();
|
return this.nativeChannel(context, 'getHeight')();
|
||||||
}
|
}
|
||||||
|
getX(context) {
|
||||||
|
return this.nativeChannel(context, 'getX')();
|
||||||
|
}
|
||||||
|
getY(context) {
|
||||||
|
return this.nativeChannel(context, 'getY')();
|
||||||
|
}
|
||||||
getLocationOnScreen(context) {
|
getLocationOnScreen(context) {
|
||||||
return this.nativeChannel(context, "getLocationOnScreen")();
|
return this.nativeChannel(context, "getLocationOnScreen")();
|
||||||
}
|
}
|
||||||
|
@ -1742,6 +1742,12 @@ class View {
|
|||||||
getHeight(context) {
|
getHeight(context) {
|
||||||
return this.nativeChannel(context, 'getHeight')();
|
return this.nativeChannel(context, 'getHeight')();
|
||||||
}
|
}
|
||||||
|
getX(context) {
|
||||||
|
return this.nativeChannel(context, 'getX')();
|
||||||
|
}
|
||||||
|
getY(context) {
|
||||||
|
return this.nativeChannel(context, 'getY')();
|
||||||
|
}
|
||||||
getLocationOnScreen(context) {
|
getLocationOnScreen(context) {
|
||||||
return this.nativeChannel(context, "getLocationOnScreen")();
|
return this.nativeChannel(context, "getLocationOnScreen")();
|
||||||
}
|
}
|
||||||
|
2
doric-js/index.d.ts
vendored
2
doric-js/index.d.ts
vendored
@ -241,6 +241,8 @@ declare module 'doric/lib/src/ui/view' {
|
|||||||
nativeChannel(context: BridgeContext, name: string): (args?: any) => Promise<any>;
|
nativeChannel(context: BridgeContext, name: string): (args?: any) => Promise<any>;
|
||||||
getWidth(context: BridgeContext): Promise<number>;
|
getWidth(context: BridgeContext): Promise<number>;
|
||||||
getHeight(context: BridgeContext): Promise<number>;
|
getHeight(context: BridgeContext): Promise<number>;
|
||||||
|
getX(context: BridgeContext): Promise<number>;
|
||||||
|
getY(context: BridgeContext): Promise<number>;
|
||||||
getLocationOnScreen(context: BridgeContext): Promise<{
|
getLocationOnScreen(context: BridgeContext): Promise<{
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
2
doric-js/lib/src/ui/view.d.ts
vendored
2
doric-js/lib/src/ui/view.d.ts
vendored
@ -134,6 +134,8 @@ export declare abstract class View implements Modeling, IView {
|
|||||||
nativeChannel(context: BridgeContext, name: string): (args?: any) => Promise<any>;
|
nativeChannel(context: BridgeContext, name: string): (args?: any) => Promise<any>;
|
||||||
getWidth(context: BridgeContext): Promise<number>;
|
getWidth(context: BridgeContext): Promise<number>;
|
||||||
getHeight(context: BridgeContext): Promise<number>;
|
getHeight(context: BridgeContext): Promise<number>;
|
||||||
|
getX(context: BridgeContext): Promise<number>;
|
||||||
|
getY(context: BridgeContext): Promise<number>;
|
||||||
getLocationOnScreen(context: BridgeContext): Promise<{
|
getLocationOnScreen(context: BridgeContext): Promise<{
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
@ -168,6 +168,12 @@ export class View {
|
|||||||
getHeight(context) {
|
getHeight(context) {
|
||||||
return this.nativeChannel(context, 'getHeight')();
|
return this.nativeChannel(context, 'getHeight')();
|
||||||
}
|
}
|
||||||
|
getX(context) {
|
||||||
|
return this.nativeChannel(context, 'getX')();
|
||||||
|
}
|
||||||
|
getY(context) {
|
||||||
|
return this.nativeChannel(context, 'getY')();
|
||||||
|
}
|
||||||
getLocationOnScreen(context) {
|
getLocationOnScreen(context) {
|
||||||
return this.nativeChannel(context, "getLocationOnScreen")();
|
return this.nativeChannel(context, "getLocationOnScreen")();
|
||||||
}
|
}
|
||||||
|
6
doric-web/dist/index.js
vendored
6
doric-web/dist/index.js
vendored
@ -1800,6 +1800,12 @@ class View {
|
|||||||
getHeight(context) {
|
getHeight(context) {
|
||||||
return this.nativeChannel(context, 'getHeight')();
|
return this.nativeChannel(context, 'getHeight')();
|
||||||
}
|
}
|
||||||
|
getX(context) {
|
||||||
|
return this.nativeChannel(context, 'getX')();
|
||||||
|
}
|
||||||
|
getY(context) {
|
||||||
|
return this.nativeChannel(context, 'getY')();
|
||||||
|
}
|
||||||
getLocationOnScreen(context) {
|
getLocationOnScreen(context) {
|
||||||
return this.nativeChannel(context, "getLocationOnScreen")();
|
return this.nativeChannel(context, "getLocationOnScreen")();
|
||||||
}
|
}
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user