Last active
          March 14, 2020 16:29 
        
      - 
      
- 
        Save cedmond/8851979 to your computer and use it in GitHub Desktop. 
    Check for breakpoints on window resize
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $j(window).on('load resize',function(){ | |
| sizeCheck(); | |
| }); | |
| var currentBreak = -1; | |
| var breakpoints = [788,522,320,0]; | |
| function sizeCheck() { | |
| var screenBreak; | |
| var screenW = $j(window).width(); | |
| for (var i = 0; i < breakpoints.length; i++) { | |
| if( screenW > breakpoints[i]){ | |
| screenBreak = i; | |
| break; | |
| } | |
| } | |
| if (screenBreak != currentBreak) { | |
| currentBreak = screenBreak; | |
| var bp = breakpoints[i]; //this will be the px value defined in the breakpoints array | |
| switch( currentBreak ){ | |
| case 0 : /* the first breakpoint or larger*/ ; break; | |
| case 1 : /* second */ ; break; | |
| case 2 : /* third */; break; | |
| default : /* stuff that happens below the lowest one */; | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment