Skip to content

Commit

Permalink
🐛 Fix TimePicker position flick in IE
Browse files Browse the repository at this point in the history
  • Loading branch information
happyboy000916 committed May 20, 2019
1 parent 06480bd commit 0f3e08e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rc-time-picker",
"version": "3.6.4",
"version": "3.6.5",
"description": "React TimePicker",
"keywords": [
"react",
Expand Down Expand Up @@ -70,6 +70,7 @@
"classnames": "2.x",
"moment": "2.x",
"prop-types": "^15.5.8",
"raf": "^3.4.1",
"rc-trigger": "^2.2.0"
}
}
12 changes: 5 additions & 7 deletions src/Select.jsx
Expand Up @@ -3,22 +3,20 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDom from 'react-dom';
import classNames from 'classnames';
import raf from 'raf';

const scrollTo = (element, to, duration) => {
const requestAnimationFrame =
window.requestAnimationFrame ||
function requestAnimationFrameTimeout() {
return setTimeout(arguments[0], 10); // eslint-disable-line
};
// jump to target if duration zero
if (duration <= 0) {
element.scrollTop = to;
raf(() => {
element.scrollTop = to;
});
return;
}
const difference = to - element.scrollTop;
const perTick = (difference / duration) * 10;

requestAnimationFrame(() => {
raf(() => {
element.scrollTop += perTick;
if (element.scrollTop === to) return;
scrollTo(element, to, duration - 10);
Expand Down

0 comments on commit 0f3e08e

Please sign in to comment.