Skip to content

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

Description

@RexYao97

这个功能有个问题,如果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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions