Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2012, 09:45 PM   PM User | #1
ted.johnson0988
New Coder

 
Join Date: May 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
ted.johnson0988 is an unknown quantity at this point
How can I make an image slide across the screen when another object loads?

Alright, this is REALLY convoluted but I think it would be cool

I have a music player on my blog:
Code:
<!--SCM Music Player by Adrian C Shum - http://scmplayer.net-->
<script type="text/javascript" src="http://scmplayer.net/script.js" ></script>
<script type="text/javascript">
SCMMusicPlayer.init("{'skin':'skins/black/skin.css','playback':{'autostart':'true','shuffle':'true','volume':'40'},'playlist':[{'title':'2Spooky Battle','url':'http://a.tumblr.com/tumblr_mbdoptQ5LT1rte8jio1.mp3'}],'placement':'bottom','showplaylist':'false'}");
</script>
<!--End of SCM Music Player script-->
And I also have two pictures:
Code:
<html>
<head>
<style type="text/css">

#img1{
  position: fixed;
  right: 10px;
  bottom: 100px;
  z-index: 10;
}

#img2{
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 10;
}

</style>
</head>

<body>
  <img src="IMAGE1.png" id="img1">
  <img src="IMAGE2.png" id="img2">
</body>
</html>
I want img1 to slide from the left side of the screen to its fixed position on the right over the span of 2.6 (or 3, if decimals aren't possible) seconds. But this should only happen after the music starts playing (so it should domino after its loaded and autoplays). (From there, if possible, I'd like img1 to just hover up and down but I can live without that.)

Then I'd like img2 to just appear AFTER img1 has finished its initial animation (the slide across the screen). That needs to do nothing but just stay there.

The final and most important piece of the puzzle is that this can only happen ONCE. This is a blog so I don't want the pictures to re-load if someone goes to the next page. The music player has this property already but I'd like it for the pictures.


This is horribly complicated, I know, and I'm sorry to even be asking. But I think it would be really cool to get done.
ted.johnson0988 is offline   Reply With Quote
Old 10-05-2012, 04:47 PM   PM User | #2
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,007
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
If the player has a means to communicate to javascript outside of itself you can set the action off once playback starts (assuming they have the state change trigger an event for javascript to use).

I am probably not explaining that well, but for an example...

The JW FLV player from longtail has the ability to add "callback" functions for certain state changes within the flash player. So you can trigger events on track change, volume change, track scan, track buffer, play, pause, playlist change, etc.

The way to do that with the JW FLV player is something like this:

Code:
	jwplayer('my_player').setup({
		flashplayer: '/path/to/player.swf',
		file: '/path/to/playlist.xml,
		height: 300,
		width: 400,
		skin: '/path/to/player/skin.xml',
		volume: 50,
		events: {
			onReady: function(){
				//this javascript will be executed when the player itself is finished loading...
				do_something();
			},
			onPlay: function(){
				//this javascript will be executed when a track starts to play...
				do_another_thing();
			},
			onComplete: function(){
				//this javascript will be executed when a the player reaches the end of any single track...
				do_one_more_thing();
			}
		}
	});
The "onReady" or "on<whatever>" items are based on a list of available triggers built into the player (you can check the documentation if you need it) and the code afterward is the script that will be executed when the player's event trigger is fired.

If the player you are using has similar functionality then it is as simple as adding a callback function in the player's initialization so that you can trigger the image effect once buffering ends and playback begins. If not, then you might consider switching to the JW FLV player.

But in any case, this is a javascript question and not an HTML/CSS question. Please contact a moderator to have your thread moved to the appropriate section. (Do not cross-post!)
__________________
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
Seek and you shall find... basically:
validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting
Rowsdower! is offline   Reply With Quote
Old 10-05-2012, 04:52 PM   PM User | #3
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
Your music is way too long. You should shorten it. You need javascript or jquery to make changes in the html. Easier to do the animation with jquery, so that's what i did. We may have to add a delay to the start of the animation but this is what I have. Change your body to this:
Code:
<body>
  <img src="IMAGE1.png" id="img1">
  <img src="IMAGE2.png" id="img2">

<script type='text/javascript' src='javascript/jquery.js'></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#img1').animate({left:'900px'}, 26000,function(){
		$('#img1').attr('left','900px');
		$('#img2').css("display","block");
	});
});
</script>
<script type="text/javascript" src="http://scmplayer.net/script.js" ></script>
<script type="text/javascript">
SCMMusicPlayer.init("{'skin':'skins/black/skin.css','playback':{'autostart':'true','shuffle':'true','volume':'40'},'playlist':[{'title':'2Spooky Battle','url':'http://a.tumblr.com/tumblr_mbdoptQ5LT1rte8jio1.mp3'}],'placement':'bottom','showplaylist':'false'}");
</script>
</body>
You might want to play with the animation speed That's the number 26000 OR the final placement of img 1
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Tags
css, html, java, moving picture, music player

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:53 AM.


Advertisement
Log in to turn off these ads.