Skip to content

Commit

Permalink
pic show
Browse files Browse the repository at this point in the history
  • Loading branch information
sowdf committed Mar 12, 2016
1 parent 08e2733 commit a6c6662
Show file tree
Hide file tree
Showing 12 changed files with 591 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/dictionaries/caozhihui.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/javascript.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

300 changes: 300 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions javascript中的运动/js中的运动.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script>
window.onload = function(){

var oDiv = document.getElementById('div1');
oDiv.onclick = function(){
startMove(this, {
width:200,
height:300
},10);
}
}
function startMove( obj, json,fn ){
clearInterval(obj.iTimer);
var iCur = 0;
var iSpeed = 0;
obj.iTimer = setInterval(function(){
var iBtn = true;
for(var attr in json){
var iTarget = json[attr];
if(attr == 'opacity'){
iCur = Math.round(css(obj,'opacity') * 100);
}else{
iCur = parseInt(css(obj,attr))
}
iSpeed = (iTarget - iCur ) * 0.2;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);

if (iCur != iTarget) {
iBtn = false;
if(attr =='opacity'){
obj.style.opacity = (iCur + iSpeed) / 100;
obj.style.filter = 'alpha(opacity='+(iCur + iSpeed)+')';
}else{
obj.style[attr] = iCur + iSpeed + 'px';
}
}
}
if(iBtn){
clearInterval(obj.iTimer);
fn && fn.call(obj);
}
},30);

}
function css(obj, attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj, false)[attr];
}
}
</script>
<style>
#div1 { width:100px; height:100px; background:red; sss}
</style>
<body>
<div id="div1">

</div>
</body>
</html>
43 changes: 43 additions & 0 deletions javascript中的运动/startMove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Created by caozhihui on 16/3/12.
*/
function startMove( obj, json,fn ){
clearInterval(obj.iTimer);
var iCur = 0;
var iSpeed = 0;
obj.iTimer = setInterval(function(){
var iBtn = true;
for(var attr in json){
var iTarget = json[attr];
if(attr == 'opacity'){
iCur = Math.round(css(obj,'opacity') * 100);
}else{
iCur = parseInt(css(obj,attr))
}
iSpeed = (iTarget - iCur ) * 0.2;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);

if (iCur != iTarget) {
iBtn = false;
if(attr =='opacity'){
obj.style.opacity = (iCur + iSpeed) / 100;
obj.style.filter = 'alpha(opacity='+(iCur + iSpeed)+')';
}else{
obj.style[attr] = iCur + iSpeed + 'px';
}
}
}
if(iBtn){
clearInterval(obj.iTimer);
fn && fn.call(obj);
}
},30);

}
function css(obj, attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj, false)[attr];
}
}
70 changes: 70 additions & 0 deletions javascript中的运动/图片展示.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style>
ul { width:330px; margin:100px auto; position:relative; }
ul li { list-style:none; float:left; width:100px; height:100px; background:red; margin:10px 0 0 10px; }
</style>
<script src="startMove.js"></script>
<script>
window.onload = function(){
var oUl = document.getElementById('ul1');
var aLi = oUl.getElementsByTagName('li');
/*
* 存在的问题
* 要使视觉保持一致
* position优先解析问题 同一块内
* offsetLeft 问题
* 要使放大的时候位置不变,left,top 增加宽高的一半
* */
var arr = [];
var zIndex = 1;
for(var i=0; i<aLi.length; i++){
arr.push({left:aLi[i].offsetLeft,top:aLi[i].offsetTop})
}
for(var i=0; i<aLi.length; i++){
aLi[i].index = i;
aLi[i].style.left = arr[i].left + 'px';
aLi[i].style.top = arr[i].top + 'px';
aLi[i].style.position = 'absolute';
//位置变动重置margin
aLi[i].style.margin = 0;
aLi[i].onmouseover = function(){
this.style.zIndex = zIndex++;
this.style.background = 'green';
startMove(this,{
width : 200,
height :200,
left : arr[this.index].left - 50,
top : arr[this.index].top - 50
});
}
aLi[i].onmouseout = function(){
this.style.background = 'red';
startMove(this,{
width : 100,
height :100,
left : arr[this.index].left,
top : arr[this.index].top
});
}
}
}
</script>
<body>
<ul id="ul1">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
31 changes: 31 additions & 0 deletions javascript中的运动/缓冲原理.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style>
div{ width:100px; height:100px; position:absolute; top:0; left:800px; background:red; }
</style>
<script>
window.onload = function(){
var oDiv = document.getElementById('div1');
oDiv.onclick = function(){
var timer = null;
timer = setInterval(function(){
var iSpeed = (500 - oDiv.offsetLeft) * 0.3;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
if( oDiv.offsetLeft == 500){
clearInterval(timer);
}
oDiv.style.left = oDiv.offsetLeft + iSpeed + 'px';
},30);
}
}
</script>
<body>
<div id="div1">

</div>
</body>
</html>
6 changes: 6 additions & 0 deletions javascript中的运动/问题.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
公用定时器的问题
多值运动的问题
定时器问题
同时运动的问题
回调
加减速

0 comments on commit a6c6662

Please sign in to comment.