Skip to main content
Version: Next

GifImageView

API Reference: UI.GifImageView

GifImageView is like an ImageView which provides displaying GifImages. It lets to manage start and stop durations and behaviors, so this makes possible more flexible usage.

note

The components in the example are added from the code for better showcase purposes. To learn more about the subject you can refer to:

Adding Component From Code

As a best practice, Smartface recommends using the WYSIWYG editor in order to add components and styles to your page or library. To learn how to use UI Editor better, please refer to this documentation

UI Editor Basics
scripts/pages/pageSample.ts
import PageSampleDesign from "generated/pages/pageSample";
import Application from "@smartface/native/application";
import System from "@smartface/native/device/system";
import GifImageView from "@smartface/native/ui/gifimageview";
import { Route, Router } from "@smartface/router";
import { styleableComponentMixin } from "@smartface/styling-context";

class StyleableGifImageView extends styleableComponentMixin(GifImageView) {}

//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
myGifImageView: StyleableGifImageView;

constructor(private router?: Router, private route?: Route) {
super({});
}

// The page design has been made from the code for better
// showcase purposes. As a best practice, remove this and
// use WYSIWYG editor to style your pages.
centerizeTheChildrenLayout() {
this.style.apply({
flexProps: {
flexDirection: "ROW",
justifyContent: "CENTER",
alignItems: "CENTER",
},
});
}

onShow() {
super.onShow();
const { headerBar } =
System.OS === System.OSType.ANDROID ? this : this.parentController;
Application.statusBar.visible = false;
headerBar.visible = false;
}

onLoad() {
super.onLoad();
this.centerizeTheChildrenLayout();

this.myGifImageView = new StyleableGifImageView({});
this.myGifImageView.loadFromUrl({
url: "https://newcdnsmartface.blob.core.windows.net/docs/samples/gif-example.gif",
});
// setTimeout(() => this.myGifImageView.stopAnimating(), 3000);

this.addChild(this.myGifImageView, "myGifImageView", ".gifImageView", {
width: 200,
height: 200,
});
}
}