2012-07-01 83 views
0

我期待將以下腳本從初始滑動操作更改爲初始滑動* 以上 *操作。我不能使用Jquery,只能使用普通的JS。更改dhtmlgoodies滑動滑動

目前當內容進入時,它下滑。我希望它能夠向上滑動。

感謝您的幫助!

<pre> 
<script language="javascript" type="text/javascript"> 

var initHeight = 0; 
var slidedown_direction = 1; 
var slidedownContentBox = false; 
var slidedownContent = false; 
var slidedownActive = false; 
var contentHeight = false; 
var slidedownSpeed = 3; // Higher value = faster script 
var slidedownTimer = 7; // Lower value = faster script 

function slidedown_showHide() { 
    if(initHeight==0)slidedown_direction=slidedownSpeed; else slidedown_direction = slidedownSpeed*-1; 
    if(!slidedownContentBox) { 
    slidedownContentBox = document.getElementById('dhtmlgoodies_contentBox'); 
    slidedownContent = document.getElementById('dhtmlgoodies_content'); 
    contentHeight = document.getElementById('dhtmlgoodies_content').offsetHeight; 
    } 
    slidedownContentBox.style.visibility='visible'; 
    slidedownActive = true; 
    slidedown_showHide_start(); 
} 

function slidedown_showHide_start() { 
    if(!slidedownActive)return; 
    initHeight = initHeight/1 + slidedown_direction; 
    if(initHeight <= 0) { 
    slidedownActive = false; 
    slidedownContentBox.style.visibility='hidden'; 
    initHeight = 0; 
    } 
    if(initHeight>contentHeight) { 
    slidedownActive = false; 
    } 
    slidedownContentBox.style.height = initHeight + 'px'; 
    slidedownContent.style.top = initHeight - contentHeight + 'px'; 
    setTimeout('slidedown_showHide_start()',slidedownTimer); // Choose a lower value than 10 to make the script move faster 
} 

function setslidedownWidth(newWidth) { 
    document.getElementById('dhtmlgoodies_slidedown').style.width = newWidth + 'px'; 
    document.getElementById('dhtmlgoodies_contentBox').style.width = newWidth + 'px'; 
} 

function setSlideDownSpeed(newSpeed) { 
    slidedownSpeed = newSpeed; 
} 

</script> 
</pre> 

回答

0

使用bottom,而不是top

slidedownContent.style.bottom = initHeight - contentHeight + 'px'; 

或添加,而不是減法:

slidedownContent.style.top = initHeight + contentHeight + 'px';