Recalculating offset from top

Recalculating offset from top

I have a function setup that detects the offset from the top -- it's working just fine on load, but when the orientation changes, it won't recalculate. I thought "orientationchange" covered that, but for some reason it doesn't force a new offset. Any help would be greatly appreciated (been testing this far too long :/).


  
  1. $(document).ready(function() {
  2. var menu_hdr = $("[id^=table-] .divwrap").offset().top,$window = $(window);
  3. var menu_end_check = $(".table tbody tr:nth-last-child(9)").offset().top,$window = $(window);


  4. $(window).on("scroll resize orientationchange", function stickymenu() {
  5. var y_scroll_pos = window.pageYOffset;
  6. var menu_header = menu_hdr;
  7. var menu_footer_check = menu_end_check;
  8. if((y_scroll_pos >= menu_header) && (y_scroll_pos < menu_footer_check)) {

  9. /* do stuff */

  10. }

  11. });
  12. });