Skip to content

Commit

Permalink
fixes #1883 text offset
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymovin committed Nov 29, 2019
1 parent 48bc5e7 commit c0590a8
Showing 1 changed file with 29 additions and 37 deletions.
66 changes: 29 additions & 37 deletions player/js/utils/text/TextSelectorProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,65 +55,57 @@ var TextSelectorProp = (function(){
var s = this.finalS;
var e = this.finalE;
var type = this.data.sh;
if(type == 2){
if(e === s){
if (type === 2){
if (e === s) {
mult = ind >= e ? 1 : 0;
}else{
mult = max(0,min(0.5/(e-s) + (ind-s)/(e-s),1));
} else {
mult = max(0, min(0.5 / (e - s) + (ind - s) / (e - s), 1));
}
mult = easer(mult);
}else if(type == 3){
if(e === s){
} else if(type === 3) {
if (e === s) {
mult = ind >= e ? 0 : 1;
}else{
mult = 1 - max(0,min(0.5/(e-s) + (ind-s)/(e-s),1));
mult = 1 - max(0, min(0.5 / (e - s) + (ind - s) / (e - s),1));
}

mult = easer(mult);
}else if(type == 4){
if(e === s){
} else if (type === 4) {
if (e === s) {
mult = 0;
}else{
mult = max(0,min(0.5/(e-s) + (ind-s)/(e-s),1));
if(mult<0.5){
} else {
mult = max(0, min(0.5 / (e - s) + (ind - s) / (e - s), 1));
if (mult < 0.5) {
mult *= 2;
}else{
mult = 1 - 2*(mult-0.5);
} else {
mult = 1 - 2 * (mult - 0.5);
}
}
mult = easer(mult);
}else if(type == 5){
if(e === s){
} else if (type === 5) {
if (e === s){
mult = 0;
}else{
} else {
var tot = e - s;
/*ind += 0.5;
mult = -4/(tot*tot)*(ind*ind)+(4/tot)*ind;*/
ind = min(max(0,ind+0.5-s),e-s);
ind = min(max(0, ind + 0.5 - s), e - s);
var x = -tot/2+ind;
var a = tot/2;
mult = Math.sqrt(1 - (x*x)/(a*a));
mult = Math.sqrt(1 - (x * x) / (a * a));
}
mult = easer(mult);
}else if(type == 6){
if(e === s){
} else if (type === 6) {
if (e === s){
mult = 0;
}else{
ind = min(max(0,ind+0.5-s),e-s);
mult = (1+(Math.cos((Math.PI+Math.PI*2*(ind)/(e-s)))))/2;
/*
ind = Math.min(Math.max(s,ind),e-1);
mult = (1+(Math.cos((Math.PI+Math.PI*2*(ind-s)/(e-1-s)))))/2;
mult = Math.max(mult,(1/(e-1-s))/(e-1-s));*/
} else {
ind = min(max(0, ind + 0.5 - s), e - s);
mult = (1 + (Math.cos((Math.PI + Math.PI * 2 * (ind) / (e - s))))) / 2;
}
mult = easer(mult);
}else {
if(ind >= floor(s)){
if(ind-s < 0){
mult = 1 - (s - ind);
}else{
mult = max(0,min(e-ind,1));
}
} else {
if (ind >= floor(s)) {
mult = max(0, min(e - s - ind, 1));
}
mult = easer(mult);
}
Expand All @@ -135,8 +127,8 @@ var TextSelectorProp = (function(){
s = e;
e = _s;
}
this.finalS = s;
this.finalE = e;
this.finalS = max(0, min(s, this.data.totalChars));
this.finalE = max(0, min(e, this.data.totalChars));
}
}
extendPrototype([DynamicPropertyContainer], TextSelectorProp);
Expand Down

0 comments on commit c0590a8

Please sign in to comment.