Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This function is used to animate the given feature to the given
- * location. Valid locations are "left", "right", "center", "hidden"
- */
- var animateFeature = function($feature, direction)
- {
- var new_width, new_height, new_top, new_left, new_zindex, new_padding, new_fade;
- // Determine the old and new positions of the feature
- var oldPosition = $feature.data('position');
- var newPosition;
- if (direction == true)
- newPosition = getPreviousNum(oldPosition);
- else
- newPosition = getNextNum(oldPosition);
- // callback for moving out of center pos
- if (oldPosition == 1) {
- options.leavingCenter($feature);
- }
- // Caculate new new css values depending on where the feature will be located
- if (newPosition == 1) {
- new_width = pluginData.largeFeatureWidth;
- new_height = pluginData.largeFeatureHeight;
- new_top = options.topPadding;
- new_zindex = $feature.css("z-index");
- new_left = (pluginData.containerWidth / 2) - (pluginData.largeFeatureWidth / 2) - (pluginData.borderWidth / 2);
- new_fade = 1.0;
- $feature.addClass("featSlide");
- } else {
- new_width = pluginData.smallFeatureWidth;
- new_height = pluginData.smallFeatureHeight;
- new_top = options.smallFeatureOffset + options.topPadding;
- new_zindex = 1;
- new_fade = 0.4;
- $feature.removeClass("featSlide");
- $feature.addClass("featSlide");
- // some info is different for the left, right, and hidden positions
- // left
- if (newPosition == pluginData.totalFeatureCount) {
- new_left = options.sidePadding;
- // right
- } else if (newPosition == 2) {
- new_left = pluginData.containerWidth - pluginData.smallFeatureWidth - options.sidePadding - pluginData.borderWidth;
- // hidden
- } else {
- new_left = (pluginData.containerWidth / 2) - (pluginData.smallFeatureWidth / 2) - (pluginData.borderWidth / 2);
- new_fade = 0;
- }
- }
- // This code block takes care of hiding the feature information if the feature is leaving the center
- if (oldPosition == 1) {
- // Slide up the story information
- $feature.find(".carousel-caption")
- .hide();
- }
Add Comment
Please, Sign In to add comment