Skip to content

Commit

Permalink
Added fix for hiding bare text in a carousel first item appearing in …
Browse files Browse the repository at this point in the history
…the pad items.[ticket #146]
  • Loading branch information
Michael Mathews committed Oct 15, 2009
1 parent 6a07139 commit badfd09
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/widgets/carousel/carousel.js
Expand Up @@ -539,7 +539,6 @@
}
}


// the number of pads needed differs if we're looping or not
if (this._opts.loop) {
// pad items to an even step, prevents carousel getting out of step
Expand All @@ -559,6 +558,17 @@
pad.removeAttr("id");
pad.addClass("carousel-added");
pad.addClass("carousel-pad");

// in order to set visibility of text nodes to hidden they must be wrapped in an element
for (var i = pad[0].childNodes.length-1; i >= 0; i--) {
var padChild = pad[0].childNodes[i];
if (padChild.nodeType === 3) { // is it a text node?
var wrappedPadChild = document.createElement('span');
wrappedPadChild.innerHTML = padChild.nodeValue;
pad[0].replaceChild(wrappedPadChild, padChild);
}
}

/*debug*///pad.html("PAD");
pad.children().css("visibility", "hidden"); // keep the same dimensions as the model, but don't display anything

Expand Down

0 comments on commit badfd09

Please sign in to comment.