dont't refresh visual when no changes
This commit is contained in:
parent
932657df6d
commit
0f4fff4486
@ -51,6 +51,8 @@ export class Visual implements IVisual {
|
|||||||
private selectionManager: powerbi.extensibility.ISelectionManager;
|
private selectionManager: powerbi.extensibility.ISelectionManager;
|
||||||
private innerContainer!: HTMLDivElement;
|
private innerContainer!: HTMLDivElement;
|
||||||
private animationPlaying: boolean = true;//控制动画暂停
|
private animationPlaying: boolean = true;//控制动画暂停
|
||||||
|
private data:IPicsScrollerData;
|
||||||
|
private containerSize:number[];
|
||||||
constructor(options: VisualConstructorOptions) {
|
constructor(options: VisualConstructorOptions) {
|
||||||
this.container = options.element;
|
this.container = options.element;
|
||||||
this.host=options.host;
|
this.host=options.host;
|
||||||
@ -73,28 +75,30 @@ export class Visual implements IVisual {
|
|||||||
this.container.appendChild(this.innerContainer);
|
this.container.appendChild(this.innerContainer);
|
||||||
}
|
}
|
||||||
public update(options: VisualUpdateOptions) {
|
public update(options: VisualUpdateOptions) {
|
||||||
let settings = Visual.parseSettings(options && options.dataViews && options.dataViews[0]);
|
|
||||||
this.settings=settings;
|
|
||||||
this.initial();
|
|
||||||
//处理输入
|
|
||||||
|
|
||||||
|
let settings = Visual.parseSettings(options && options.dataViews && options.dataViews[0]);
|
||||||
let data: IPicsScrollerData = { urls: <string[]>options.dataViews[0].categorical.categories[0].values };
|
let data: IPicsScrollerData = { urls: <string[]>options.dataViews[0].categorical.categories[0].values };
|
||||||
|
let containerSize=[options.viewport.width,options.viewport.height];
|
||||||
|
|
||||||
|
//处理输入
|
||||||
//feet
|
//feet
|
||||||
settings.animation.stepLength=(settings.animation.stepLength>=0&&settings.animation.stepLength<=100)?settings.animation.stepLength:1;
|
settings.animation.stepLength=(settings.animation.stepLength>=0&&settings.animation.stepLength<=100)?settings.animation.stepLength:1;
|
||||||
let feet = options.viewport.width / 100 * settings.animation.stepLength;
|
let feet = options.viewport.width / 100 * settings.animation.stepLength;
|
||||||
//interval
|
//interval
|
||||||
settings.animation.interval=settings.animation.interval>0?settings.animation.interval:100;
|
settings.animation.interval=settings.animation.interval>0?settings.animation.interval:100;
|
||||||
let interval = this.settings.animation.interval;
|
let interval = settings.animation.interval;
|
||||||
|
|
||||||
|
|
||||||
//rowGap
|
//rowGap
|
||||||
settings.layout.rowGap=(settings.layout.rowGap>=0&&settings.layout.rowGap<=100)?settings.layout.rowGap:0;
|
settings.layout.rowGap=(settings.layout.rowGap>=0&&settings.layout.rowGap<=100)?settings.layout.rowGap:0;
|
||||||
let rowGap = options.viewport.height / 100 * settings.layout.rowGap;
|
let rowGap = options.viewport.height / 100 * settings.layout.rowGap;
|
||||||
//columnGap
|
//columnGap
|
||||||
settings.layout.columnGap=(settings.layout.columnGap>=0&&settings.layout.columnGap<=100)?settings.layout.columnGap:0;
|
settings.layout.columnGap=(settings.layout.columnGap>=0&&settings.layout.columnGap<=100)?settings.layout.columnGap:0;
|
||||||
let columnGap = options.viewport.width / 100 * this.settings.layout.columnGap;
|
let columnGap = options.viewport.width / 100 * settings.layout.columnGap;
|
||||||
|
|
||||||
//rowsCount
|
//rowsCount
|
||||||
settings.layout.rowsCount=settings.layout.rowsCount>=1?Math.floor(settings.layout.rowsCount):1;
|
settings.layout.rowsCount=settings.layout.rowsCount>=1?Math.floor(settings.layout.rowsCount):1;
|
||||||
let rowsCount=this.settings.layout.rowsCount;
|
let rowsCount=settings.layout.rowsCount;
|
||||||
|
|
||||||
|
|
||||||
if (!(data.urls.length > 0) || !(rowsCount! > 0)) {
|
if (!(data.urls.length > 0) || !(rowsCount! > 0)) {
|
||||||
console.info("picsScroller error: (source_url.length,rowsCount) ", data.urls.length + "_" + rowsCount);
|
console.info("picsScroller error: (source_url.length,rowsCount) ", data.urls.length + "_" + rowsCount);
|
||||||
@ -103,6 +107,28 @@ export class Visual implements IVisual {
|
|||||||
if (rowsCount > data.urls.length) {
|
if (rowsCount > data.urls.length) {
|
||||||
rowsCount = data.urls.length;
|
rowsCount = data.urls.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.debug("data",JSON.stringify(data));
|
||||||
|
console.debug("this.data",JSON.stringify(this.data));
|
||||||
|
console.debug("settings",JSON.stringify(settings));
|
||||||
|
console.debug("this.settings",JSON.stringify(this.settings));
|
||||||
|
console.debug("containerSize",JSON.stringify(containerSize));
|
||||||
|
console.debug("this.containerSize",JSON.stringify(this.containerSize));
|
||||||
|
let justifyEqual=function(a:any,b:any){
|
||||||
|
return JSON.stringify(a)==JSON.stringify(b);
|
||||||
|
};
|
||||||
|
//判断是否完全无需刷新
|
||||||
|
if(justifyEqual(this.data,data)&&justifyEqual(this.settings,settings)&&justifyEqual(this.containerSize,containerSize)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//必要的类
|
||||||
|
this.initial();
|
||||||
|
this.data=data;
|
||||||
|
this.settings=settings;
|
||||||
|
this.containerSize=containerSize;
|
||||||
|
|
||||||
|
//数据转换
|
||||||
let brandsCount = data.urls.length;
|
let brandsCount = data.urls.length;
|
||||||
let unitsCountPerRow = Math.floor(brandsCount / rowsCount);
|
let unitsCountPerRow = Math.floor(brandsCount / rowsCount);
|
||||||
let logoUrlsArr: string[][] = [];
|
let logoUrlsArr: string[][] = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user