Guest User

Untitled

a guest
Oct 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. /**
  2. * This function is used to animate the given feature to the given
  3. * location. Valid locations are "left", "right", "center", "hidden"
  4. */
  5. var animateFeature = function($feature, direction)
  6. {
  7. var new_width, new_height, new_top, new_left, new_zindex, new_padding, new_fade;
  8.  
  9. // Determine the old and new positions of the feature
  10. var oldPosition = $feature.data('position');
  11. var newPosition;
  12. if (direction == true)
  13. newPosition = getPreviousNum(oldPosition);
  14. else
  15. newPosition = getNextNum(oldPosition);
  16.  
  17. // callback for moving out of center pos
  18. if (oldPosition == 1) {
  19. options.leavingCenter($feature);
  20. }
  21.  
  22. // Caculate new new css values depending on where the feature will be located
  23. if (newPosition == 1) {
  24. new_width = pluginData.largeFeatureWidth;
  25. new_height = pluginData.largeFeatureHeight;
  26. new_top = options.topPadding;
  27. new_zindex = $feature.css("z-index");
  28. new_left = (pluginData.containerWidth / 2) - (pluginData.largeFeatureWidth / 2) - (pluginData.borderWidth / 2);
  29. new_fade = 1.0;
  30. $feature.addClass("featSlide");
  31. } else {
  32. new_width = pluginData.smallFeatureWidth;
  33. new_height = pluginData.smallFeatureHeight;
  34. new_top = options.smallFeatureOffset + options.topPadding;
  35. new_zindex = 1;
  36. new_fade = 0.4;
  37. $feature.removeClass("featSlide");
  38. $feature.addClass("featSlide");
  39.  
  40. // some info is different for the left, right, and hidden positions
  41. // left
  42. if (newPosition == pluginData.totalFeatureCount) {
  43. new_left = options.sidePadding;
  44.  
  45. // right
  46. } else if (newPosition == 2) {
  47. new_left = pluginData.containerWidth - pluginData.smallFeatureWidth - options.sidePadding - pluginData.borderWidth;
  48. // hidden
  49. } else {
  50. new_left = (pluginData.containerWidth / 2) - (pluginData.smallFeatureWidth / 2) - (pluginData.borderWidth / 2);
  51. new_fade = 0;
  52. }
  53. }
  54. // This code block takes care of hiding the feature information if the feature is leaving the center
  55. if (oldPosition == 1) {
  56. // Slide up the story information
  57. $feature.find(".carousel-caption")
  58. .hide();
  59. }
Add Comment
Please, Sign In to add comment