Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > emulating a flash based site with dynamic html/css/javascript

Reply
Thread Tools

emulating a flash based site with dynamic html/css/javascript

 
 
James
Guest
Posts: n/a
 
      11-12-2011
I was wondering if there is a way to emulate the "flowing text animation"
from the following 100% flash-based website opening page:

http://hazeltinephotography.com

I think I can do all the rest in JavaScript, however this text animation is
bothering me. Perhaps I need to use HTML 5 canvas... Hummm....


I think I could show the text as a sliding div with overflow: hidden... But
it would not be as pretty...

Are there any good IDE's for HTML 5 canvas? Perhaps I can do it in Flash CS5
and use something like Wallaby...


 
Reply With Quote
 
 
 
 
Elegie
Guest
Posts: n/a
 
      11-12-2011
On 12/11/2011 07:20, James wrote :

Hello,

> I was wondering if there is a way to emulate the "flowing text animation"
> from the following 100% flash-based website opening page:
>
> http://hazeltinephotography.com


I do not think so, because this would mean modifying how a particular
font is drawn, which AFAIK cannot be done through scripting.

> I think I can do all the rest in JavaScript, however this text animation is
> bothering me. Perhaps I need to use HTML 5 canvas... Hummm....


Well, I believe that you'd have to draw yourself the letters, that would
certainly be possible, yet quite a pain to set up.

> I think I could show the text as a sliding div with overflow: hidden... But
> it would not be as pretty...


I like a good challenge when waking up on Saturday morning, so I have
tried and built something (see below). The script comes in two parts: an
HTML page and a script include. It works fine on Chrome 15, IE9 and
Firefox 5, but I am not sure of how it will render on other (and
especially older) browsers.

Have fun,
Elegie.

----
HTML file
----
<!doctype html>
<html>
<head>
<title>Text Effect</title>
<meta charset='utf-8'>
<style type="text/css">
#top {
background-color: #aaa ;
border: 1px #000 solid;
position: absolute;
height: 40%; width: 60%;
left: 20%; top: 10%;
}
#bottom {
background-color: #000 ;
border: 1px #000 solid;
position: absolute;
height: 30%; width: 60%;
left: 20%; top: 50%;
}
#title {
color: #fff;
font-size: 2em; font-family: Segoe Script;
position: absolute;
margin-top: -0.5em; padding-left: 0.5em;
left: 20%; top: 50%;
}
</style>
<script type="text/javascript" src="text-effects.js"></script>
</head>
<body>
<div id="top"></div>
<div id="bottom"></div>
<div id="title">Illuminating the essences of nature.</div>
<script type="text/javascript">
var target = document.getElementById("title");
var effect = TextEffects.createProgressiveEffect(
TextEffects.createSmoothEffect()
);
effect.applyOnTarget(target);
</script>
</body>
</html>

----
Script file (text-effects.js)
----
var TextEffects = (function () {

var EFFECT_TIMEOUT = 42;

function createSmoothEffect (parentEffect) {
var effect = {};
effect.applyOnTarget = function(target) {
var opacity = 0;
target.style.opacity = opacity;
if (parentEffect && parentEffect.applyOnTarget) {
parentEffect.applyOnTarget(target);
}
setTimeout(
function() {
opacity += 0.1;
if (opacity<1) {
target.style.opacity = opacity;
setTimeout(arguments.callee, EFFECT_TIMEOUT);
} else {
target.style.opacity = 1;
}
},
EFFECT_TIMEOUT
);
};
return effect;
}

function createProgressiveEffect(parentEffect) {
var effect = {};
effect.applyOnTarget = function(target) {
// Main algorithm
denormalizeNodes(target);
hideNodes(target);
showNodes(target);

// Helpers
function traverse(root, actionsByNodeType) {
var children = root.childNodes;
for (var ii=0; ii<children.length; ii++) {
var child = children[ii];
var action = actionsByNodeType[child.nodeType];
if (action) {
action(child);
}
}
}

function denormalizeNodes(target) {
traverse(target, {
"1" : function(node) {
traverse(node, this);
},
"3" : function (node) {
var text = node.nodeValue;
if (text) {
var parts = text.split("");
for (var j=0; j<parts.length; j++) {
var container = document.createElement("span");
container.appendChild(
document.createTextNode(parts[j])
);
node.parentNode.insertBefore(container, node);
}
node.parentNode.removeChild(node);
}
}
});
}

function hideNodes(target) {
traverse(target, {
"1" : function(node) {
traverse(node, this);
node.style.visibility = "hidden";
}
});
}

function showNodes(target) {
var list = [];
traverse(target, {
"1" : function(node) {traverse(node, this); list.push(node);}
});

var index=0;
setTimeout(
function() {
var node = list[index++];
if(node) {
node.style.visibility = "visible";
if (parentEffect && parentEffect.applyOnTarget) {
parentEffect.applyOnTarget(node);
}
setTimeout(arguments.callee, EFFECT_TIMEOUT);
}
},
EFFECT_TIMEOUT
);
}
};

return effect;
}

return {
createSmoothEffect : createSmoothEffect,
createProgressiveEffect : createProgressiveEffect
};

})();


 
Reply With Quote
 
 
 
 
Michael Haufe (TNO)
Guest
Posts: n/a
 
      11-12-2011
On Nov 12, 12:20*am, "James" <n...@spam.invalid> wrote:
> I was wondering if there is a way to emulate the "flowing text animation"
> from the following 100% flash-based website opening page:
>
> http://hazeltinephotography.com
>
> I think I can do all the rest in JavaScript, however this text animation is
> bothering me. Perhaps I need to use HTML 5 canvas... Hummm....



SVG perhaps:

http://svg-wow.org/text-effects/text-effects.xhtml
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASA 5505 site-site VPN - other site dynamic? SteveB Cisco 0 03-26-2009 01:48 PM
Emulating referrers? Ben Fidge ASP .Net 1 12-14-2005 07:06 PM
Emulating referrers? Ben Fidge ASP .Net 0 12-14-2005 04:30 PM
Emulating variables static to the page Mike Orb ASP .Net 2 09-02-2005 03:24 PM
Emulating floating point gthorpe@ee.ryerson.ca VHDL 3 09-01-2005 09:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57