mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
TypeScript 2.5 compatibility (#4794)
This commit is contained in:
committed by
SvetoslavTsenov
parent
a79a83ce82
commit
28b6eba9ac
@@ -5,7 +5,7 @@ import { ImageSource, fromAsset, fromNativeSource, fromUrl } from "../../image-s
|
|||||||
import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils";
|
import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils";
|
||||||
|
|
||||||
export * from "../core/view";
|
export * from "../core/view";
|
||||||
export { ImageSource, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };
|
export { ImageSource, ImageAsset, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };
|
||||||
|
|
||||||
export abstract class ImageBase extends View implements ImageDefinition {
|
export abstract class ImageBase extends View implements ImageDefinition {
|
||||||
public imageSource: ImageSource;
|
public imageSource: ImageSource;
|
||||||
@@ -24,7 +24,7 @@ export abstract class ImageBase extends View implements ImageDefinition {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public _createImageSourceFromSrc(value: string | ImageSource): void {
|
public _createImageSourceFromSrc(value: string | ImageSource | ImageAsset): void {
|
||||||
const originalValue = value;
|
const originalValue = value;
|
||||||
const sync = this.loadMode === "sync";
|
const sync = this.loadMode === "sync";
|
||||||
if (typeof value === "string" || value instanceof String) {
|
if (typeof value === "string" || value instanceof String) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, Color,
|
ImageSource, ImageAsset, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, Color,
|
||||||
isDataURI, isFileOrResourcePath, RESOURCE_PREFIX
|
isDataURI, isFileOrResourcePath, RESOURCE_PREFIX
|
||||||
} from "./image-common";
|
} from "./image-common";
|
||||||
import { knownFolders } from "../../file-system";
|
import { knownFolders } from "../../file-system";
|
||||||
@@ -75,7 +75,7 @@ export class Image extends ImageBase {
|
|||||||
this.nativeViewProtected.setImageMatrix(new android.graphics.Matrix());
|
this.nativeViewProtected.setImageMatrix(new android.graphics.Matrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
public _createImageSourceFromSrc(value: string | ImageSource) {
|
public _createImageSourceFromSrc(value: string | ImageSource | ImageAsset) {
|
||||||
const imageView = this.nativeViewProtected;
|
const imageView = this.nativeViewProtected;
|
||||||
if (!imageView) {
|
if (!imageView) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Types
|
// Types
|
||||||
import {
|
import {
|
||||||
Transformation,
|
Transformation,
|
||||||
TransformationValue,
|
TransformationValue,
|
||||||
TransformFunctionsInfo,
|
TransformFunctionsInfo,
|
||||||
@@ -456,13 +456,13 @@ const TRANSFORMATIONS = Object.freeze([
|
|||||||
const STYLE_TRANSFORMATION_MAP = Object.freeze({
|
const STYLE_TRANSFORMATION_MAP = Object.freeze({
|
||||||
"scale": value => ({ property: "scale", value }),
|
"scale": value => ({ property: "scale", value }),
|
||||||
"scale3d": value => ({ property: "scale", value }),
|
"scale3d": value => ({ property: "scale", value }),
|
||||||
"scaleX": ({x}) => ({ property: "scale", value: { x, y: IDENTITY_TRANSFORMATION.scale.y } }),
|
"scaleX": ({ x }) => ({ property: "scale", value: { x, y: IDENTITY_TRANSFORMATION.scale.y } }),
|
||||||
"scaleY": ({y}) => ({ property: "scale", value: { y, x: IDENTITY_TRANSFORMATION.scale.x } }),
|
"scaleY": ({ y }) => ({ property: "scale", value: { y, x: IDENTITY_TRANSFORMATION.scale.x } }),
|
||||||
|
|
||||||
"translate": value => ({ property: "translate", value }),
|
"translate": value => ({ property: "translate", value }),
|
||||||
"translate3d": value => ({ property: "translate", value }),
|
"translate3d": value => ({ property: "translate", value }),
|
||||||
"translateX": ({x}) => ({ property: "translate", value: { x, y: IDENTITY_TRANSFORMATION.translate.y } }),
|
"translateX": ({ x }) => ({ property: "translate", value: { x, y: IDENTITY_TRANSFORMATION.translate.y } }),
|
||||||
"translateY": ({y}) => ({ property: "translate", value: { y, x: IDENTITY_TRANSFORMATION.translate.x } }),
|
"translateY": ({ y }) => ({ property: "translate", value: { y, x: IDENTITY_TRANSFORMATION.translate.x } }),
|
||||||
|
|
||||||
"rotate": value => ({ property: "rotate", value }),
|
"rotate": value => ({ property: "rotate", value }),
|
||||||
});
|
});
|
||||||
@@ -501,12 +501,12 @@ export function transformConverter(text: string): TransformFunctionsInfo {
|
|||||||
return fullTransformations;
|
return fullTransformations;
|
||||||
}
|
}
|
||||||
|
|
||||||
const affineMatrix = transformations
|
const affineMatrix = transformations
|
||||||
.map(getTransformMatrix)
|
.map(getTransformMatrix)
|
||||||
.reduce(multiplyAffine2d)
|
.reduce(multiplyAffine2d)
|
||||||
const cssMatrix = matrixArrayToCssMatrix(affineMatrix)
|
const cssMatrix = matrixArrayToCssMatrix(affineMatrix)
|
||||||
|
|
||||||
return decompose2DTransformMatrix(cssMatrix);
|
return decompose2DTransformMatrix(cssMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// using general regex and manually checking the matched
|
// using general regex and manually checking the matched
|
||||||
@@ -528,8 +528,8 @@ function parseTransformString(text: string): Transformation[] {
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeTransformation({ property, value }: Transformation) {
|
function normalizeTransformation({ property, value }: Transformation): Transformation {
|
||||||
return STYLE_TRANSFORMATION_MAP[property](value);
|
return <any>STYLE_TRANSFORMATION_MAP[property](value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertTransformValue(property: string, stringValue: string)
|
function convertTransformValue(property: string, stringValue: string)
|
||||||
|
|||||||
Reference in New Issue
Block a user