vertical.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * vertical layout mode
  3. */
  4. ( function( window, factory ) {
  5. // universal module definition
  6. /* jshint strict: false */ /*globals define, module, require */
  7. if ( typeof define == 'function' && define.amd ) {
  8. // AMD
  9. define( [
  10. '../layout-mode'
  11. ],
  12. factory );
  13. } else if ( typeof module == 'object' && module.exports ) {
  14. // CommonJS
  15. module.exports = factory(
  16. require('../layout-mode')
  17. );
  18. } else {
  19. // browser global
  20. factory(
  21. window.Isotope.LayoutMode
  22. );
  23. }
  24. }( window, function factory( LayoutMode ) {
  25. 'use strict';
  26. var Vertical = LayoutMode.create( 'vertical', {
  27. horizontalAlignment: 0
  28. });
  29. var proto = Vertical.prototype;
  30. proto._resetLayout = function() {
  31. this.y = 0;
  32. };
  33. proto._getItemLayoutPosition = function( item ) {
  34. item.getSize();
  35. var x = ( this.isotope.size.innerWidth - item.size.outerWidth ) *
  36. this.options.horizontalAlignment;
  37. var y = this.y;
  38. this.y += item.size.outerHeight;
  39. return { x: x, y: y };
  40. };
  41. proto._getContainerSize = function() {
  42. return { height: this.y };
  43. };
  44. return Vertical;
  45. }));