target
{"ScriptPreparationCode":"function gid(id) {\r\n\treturn document.getElementById(id);\r\n}\r\n\r\nduration = 400;\r\nparent = gid(\u0022parent\u0022);\r\ntarget = gid(\u0022target\u0022);\r\npreoffset = parent.offsetHeight/2 \u002B parseInt(getComputedStyle(parent).marginTop);\r\n\r\nfunction step (parent, scrolltoOffset, duration, oldtime, framereadytime) {\r\n if (!oldtime) oldtime = framereadytime;\r\n var progress = framereadytime - oldtime;\r\n\r\n //console.log(parent, target, duration);\r\n if(progress \u003C duration) {\r\n requestAnimationFrame (step.bind(null, parent, scrolltoOffset, duration, oldtime));\r\n parent.scrollTop = scrolltoOffset * progress/duration;\r\n }\r\n}\r\nfunction scrollTo (parent, target, duration) {\r\n //console.log(parent, target, duration);\r\n var oldtime = null;\r\n var scrolltoOffset = target.offsetTop - preoffset;\r\n var oldtime = null;\r\n var cb = step.bind(null, parent, scrolltoOffset, duration, oldtime);\r\n requestAnimationFrame (cb);\r\n}\r\nfunction scrollTo2 (parent, target, duration) {\r\n if(duration \u003E 600) return false;\r\n var oldtime = null;\r\n var scrolltoOffset = target.offsetTop - preoffset;\r\n var step = function (framereadytime) {\r\n if (!oldtime) oldtime = framereadytime;\r\n var progress = framereadytime - oldtime;\r\n\r\n if(progress \u003C duration) {\r\n requestAnimationFrame (step);\r\n parent.scrollTop = scrolltoOffset * progress/duration;\r\n }\r\n }\r\n requestAnimationFrame (step);\r\n}","TestCases":[{"Name":"scrollto","Code":"scrollTo (parent, target, 400);","IsDeferred":false},{"Name":"scrollto2","Code":"scrollTo2 (parent, target, 400);","IsDeferred":false}]}