I would like to cycle through an array of words, creating the effect of rotating the text. I have most of the work, as you would expect. Is there a way to use the css transition along the length of the p element?
When moving from an object with char.length> 10 to an object with char.length <5 (for example), the movement is not smooth, and I would like to facilitate the movement of text around the word, rather than suddenly jumping backward (or forward depending on the length of the word) .
HTML:
<p><span id="description-rotate"></span> something built on something else.</p>
SASS:
@-webkit-keyframes rotate-text 0% opacity: 0 30% opacity: 1 50% opacity: 1 70% opacity: 1 100% opacity: 0 p font-family: 'Helvetica', sans-serif .rotate-text -webkit-animation: rotate-text 3050ms cubic-bezier(0.645, 0.045, 0.355, 1.000) infinite -moz-animation: rotate-text 3050ms cubic-bezier(0.645, 0.045, 0.355, 1.000) infinite -o-animation: rotate-text 3050ms cubic-bezier(0.645, 0.045, 0.355, 1.000) infinite animation: rotate-text 3050ms cubic-bezier(0.645, 0.045, 0.355, 1.000) infinite
JavaScript:
var descriptionArray = ['some text', 'some more text', 'some even longer text']; var descriptionLength = descriptionArray.length; var description = $('#description-rotate'); function loop(i) { description.text(descriptionArray[i%descriptionLength]); setTimeout(function() { loop(i+1); description.addClass('rotate-text'); }, 3050);
I understand that this may be a bad way to explain my purpose, check out CodePen for a better idea of ββwhat I'm trying to create.
Thanks!
See: http://codepen.io/anon/pen/JueGx
javascript jquery css rotation fade
Cole roberts
source share