target
noid
{"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\n\r\nfunction anim (parent, target, duration) {\r\n //console.log(parent, target, duration);\r\n var oldtime = null;\r\n var scrolltoOffset = target.offsetTop - preoffset;\r\n function step (framereadytime) {\r\n if (!oldtime) oldtime = framereadytime;\r\n var progress = framereadytime - oldtime;\r\n //console.log(parent, target, duration);\r\n if(progress \u003C duration \u0026\u0026 callback(progress) !== false) {\r\n rafid = requestAnimationFrame (step);\r\n }\r\n }\r\n function callback (delta) {\r\n \tparent.scrollTop = scrolltoOffset * delta/duration;\r\n }\r\n var rafid = requestAnimationFrame (step);\r\n setTimeout(function() {\r\n \tcancelAnimationFrame(rafid);\r\n }, duration)\r\n}\r\nfunction step1 (timestamp) {\r\n if (!start) start = timestamp;\r\n \tvar progress = timestamp - start;\r\n \tparent.scrollTop = Math.min(progress*goffset / duration, goffset);\r\n \tif (progress \u003C duration) {\r\n \t\trequestAnimationFrame(step1);\r\n \t}\r\n}\r\nfunction anim1 (parent, target, duration) {\r\n \tstart = null;\r\n \tgoffset = target.offsetTop - preoffset;\r\n \trequestAnimationFrame(step1);\r\n}\r\n\r\n","TestCases":[{"Name":"","Code":"anim (parent, target, duration);","IsDeferred":false},{"Name":"test","Code":"1\u002B1","IsDeferred":false}]}