Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【filter新增平滑参数@有个问题】如果filter和map指定刚好重复的话会返回异常的值 #38

Open
RexYao97 opened this issue Jan 24, 2022 · 0 comments

Comments

@RexYao97
Copy link

这个功能有个问题,如果filter和map指定刚好重复的话会返回异常的值
例子

  <div
        class="lift-transition-sticky-content"
        tg-from="0"
        tg-to="100"
        tg-edge="cover"
        tg-name="position"
        tg-filter="0,50,100@"
        tg-map="0:50;50:0;100:0"
      ></div>

50-100的值为0,但是最终渲染的会是50,因为map也指定了0的映射值
源码问题在这

export function parseValues() {
 
 if (filter.values.length > 0 && !filter.values.includes(value)) {
      if (filter.mode === 'smooth') {
        let region = calcKeyFrameRegion(mapping, value);
       
        if (region.length) {
          // 这里获取的范围值是 0
          value = calcKeyFrameValue(mapping, value, region);
        } else {
          return;
        }
      } else {
        if (filter.mode === 'exact') {
          element.lastValue = null;
          el.style.removeProperty(name);
        }
        return;
      }
    }
  // 这里会根据value的值重新获取映射导致异常
   if (typeof mapping[value] !== 'undefined') {
      value = mapping[value];
    }

}

Originally posted by @RexYao97 in #28 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant