473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how is this done?

http://news.yahoo.com/news?tmpl=index2&cid=703

down the page, under "More Stories", there's a section with two
interchangeable divs which slide back and forth into view.. how is this
done?

I tried to reproduce this locally on my machine but can't get bottom
section (with the buttons, which user can use to make divs slide in and
out of view..) to appear, even though still linking to relevant .js files..

it's not a Flash movie, so I assume it's done with JavaScript, but can't
figure out how they make divs SCROLL with JavaScript.. it's a neat effect..

thank you..

Oct 3 '06 #1
2 1885

maya wrote:
http://news.yahoo.com/news?tmpl=index2&cid=703

down the page, under "More Stories", there's a section with two
interchangeable divs which slide back and forth into view.. how is this
done?

I tried to reproduce this locally on my machine but can't get bottom
section (with the buttons, which user can use to make divs slide in and
out of view..) to appear, even though still linking to relevant .js files..

it's not a Flash movie, so I assume it's done with JavaScript, but can't
figure out how they make divs SCROLL with JavaScript.. it's a neat effect..

thank you..
It is done using JavaScript.
e.g.

<title>play</title>
<style type="text/css">
#tickerFrame {
position: relative;
width: 152px; height: 102px;
border: 1px solid blue;
overflow: hidden;
}
#tickerHolder {
position: relative;
width: 300px; height: 100px;
border: 1px solid red;
}
#boxLeft, #boxRight {
position: absolute;
top: 0; left: 0;
width: 150px; height: 100px;
border: 1px solid green;
text-align: center;
}
#boxRight {left: 150px;}
</style>
<script type="text/javascript">
function startSlide(){
var tickerHolder = document.getEle mentById('ticke rHolder')
var tStyle, tLeft;
var low = '-150';
var high = '0';
if ( tickerHolder && (tStyle = tickerHolder.st yle) ){
if ('' == tStyle.left) tStyle.left = high + 'px';
tLeft = parseInt(tStyle .left, 10);
continueSlide(t ickerHolder, (tLeft == low)? high:low);
}
}

function continueSlide(e l, ePos){
var step = 5;
var lag = 10;
var pos = parseInt(el.sty le.left, 10);
var diff = ePos - pos;
var sign = (diff < 0)? -1 : 1;
var newPos = (Math.abs(diff) < step)? ePos : (pos + (step * sign));

if (newPos != ePos){
setTimeout( function(){cont inueSlide(el, ePos)}, lag); }
el.style.left = newPos + 'px';
}

</script>
<div id="tickerFrame ">
<div id="tickerHolde r" >
<div id="boxLeft">th e left box</div>
<div id="boxRight">t he right box</div>
</div>
</div>
<button onclick="startS lide();">Slide. ..</button>

--
Rob

Oct 4 '06 #2


RobG wrote:
maya wrote:
>http://news.yahoo.com/news?tmpl=index2&cid=703

down the page, under "More Stories", there's a section with two
interchangeabl e divs which slide back and forth into view.. how is this
done?

I tried to reproduce this locally on my machine but can't get bottom
section (with the buttons, which user can use to make divs slide in and
out of view..) to appear, even though still linking to relevant .js files..

it's not a Flash movie, so I assume it's done with JavaScript, but can't
figure out how they make divs SCROLL with JavaScript.. it's a neat effect..

thank you..

It is done using JavaScript.
e.g.

<title>play</title>
<style type="text/css">
#tickerFrame {
position: relative;
width: 152px; height: 102px;
border: 1px solid blue;
overflow: hidden;
}
#tickerHolder {
position: relative;
width: 300px; height: 100px;
border: 1px solid red;
}
#boxLeft, #boxRight {
position: absolute;
top: 0; left: 0;
width: 150px; height: 100px;
border: 1px solid green;
text-align: center;
}
#boxRight {left: 150px;}
</style>
<script type="text/javascript">
function startSlide(){
var tickerHolder = document.getEle mentById('ticke rHolder')
var tStyle, tLeft;
var low = '-150';
var high = '0';
if ( tickerHolder && (tStyle = tickerHolder.st yle) ){
if ('' == tStyle.left) tStyle.left = high + 'px';
tLeft = parseInt(tStyle .left, 10);
continueSlide(t ickerHolder, (tLeft == low)? high:low);
}
}

function continueSlide(e l, ePos){
var step = 5;
var lag = 10;
var pos = parseInt(el.sty le.left, 10);
var diff = ePos - pos;
var sign = (diff < 0)? -1 : 1;
var newPos = (Math.abs(diff) < step)? ePos : (pos + (step * sign));

if (newPos != ePos){
setTimeout( function(){cont inueSlide(el, ePos)}, lag); }
el.style.left = newPos + 'px';
}

</script>
<div id="tickerFrame ">
<div id="tickerHolde r" >
<div id="boxLeft">th e left box</div>
<div id="boxRight">t he right box</div>
</div>
</div>
<button onclick="startS lide();">Slide. ..</button>
thank you very much!! :)
Oct 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5541
by: Sugapablo | last post by:
I had an idea for something that I can't find any evidence if it exists, or if it can be done. I assume it can be done. What I'd like to be able to do, is to allow people who come to my website, click a button on the page to begin submitting an audio stream to the server. Basically, once the "record" button was hit by the client, an audio stream would be generated by the client's microphone and would be sent over port 80 (just like...
9
1727
by: Steven T. Hatton | last post by:
This was written for the gnu.g++.help list. It rather clearly spells out the most important feature of Java that I believe C++ lacks. I really don't believe the C++ Standard sepcifies enough for a generic mechanism to accomplish the comperable tasks demonstrated for Java below. I've already proposed on comp.std.c++ that the next version of the standard specify a similar functionality for a C++ implementation. I know it can be unpopular...
11
17848
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to override them. But they all invoked when the control is in the middle of the resizing process. I'm not using breakpoints, I'm using trace to see which one is invoked and when.
59
4980
by: Alan Silver | last post by:
Hello, This is NOT a troll, it's a genuine question. Please read right through to see why. I have been using Vusual Basic and Classic ASP for some years, and have now started looking at ASP.NET. At first glance, it looks excellent, albeit nothing that couldn't have been done to Classic ASP. I have been through a few tutorials and was impressed with how quickly you can get database info onto a page.
17
1749
by: blackswift | last post by:
code is from Warsaw university's CEPC code . They are world champion in the ICPC finals. #include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define FORD(i,a,b) for(int i=(a);i>=(b);--i)
12
2623
by: Ark | last post by:
Hello NG, I arrange data in structs like { members... uint16_t crc; more members, maybe... } Then I need to save them, up to and including crc, in non-volatile memory or a file, as the case may be. The data size I need for type T is offsetof(struct T, crc) +
15
1455
by: Chris | last post by:
This is just some dummy code to mimic what's being done in the real code. The actual code is python which is used as a scripting language in a third party app. The data structure returned by the app is more or less like the "data" list in the code below. The test for "ELEMENT" is necessary ... it just evaluates to true every time in this test code. In the real app perhaps 90% of tests will also be true. So my question is how can I speed...
3
2250
dfound
by: dfound | last post by:
#include<windows.h> #include<dos.h> #include<dir.h> #include<fstream.h> #include<stdio.h> #include<process.h> #include"resource.h" //resource header file
2
3376
by: poolboi | last post by:
hey guys, i've done most of my web app. for searching almost done but then i got a small little problem with logging in i need to know how session tracking is done in perl if not my log in page would truely be redundant
2
1712
by: Zerge | last post by:
I can launch threads just fine, but then I have to do a time.sleep(n) so the main thread from which they where launched will wait for all the threads to return. How can I detect when all threads are done and then return control to the main threads? Thanks for your help
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.