{"id":26994,"date":"2019-10-21T15:54:37","date_gmt":"2019-10-21T19:54:37","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=26994"},"modified":"2020-02-24T15:44:48","modified_gmt":"2020-02-24T20:44:48","slug":"wkwebview-scroll-position","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/10\/21\/wkwebview-scroll-position\/","title":{"rendered":"WKWebView Scroll Position"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/brentsimmons\/status\/1185350655176777733\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/brentsimmons\/status\/1185350655176777733\">\n<p>In NetNewsWire, I use JavaScript evaluation with a <code>WKWebView<\/code> to get the current scroll position.<\/p>\n<p>It broke in Catalina. I used <code>document.body.scrollTop<\/code> to get the y position, which appears to always return 0 now.<\/p>\n<p>Workaround: <code>window.pageYOffset<\/code> seems to work.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/dokas\/status\/1185359587144192000\">Phil Dokas<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/dokas\/status\/1185359587144192000\">\n<p>The workaround I found was <code>document.documentElement.scrollTop<\/code>. This one&rsquo;s mutable where <code>window.pageYOffset<\/code> is read-only.<\/p>\n<\/blockquote>\n\n<p>It&rsquo;s a long road to replace the <code>WebView<\/code> APIs that worked for so long.<\/p>\n\n<p><a href=\"https:\/\/ionicframework.com\/blog\/understanding-itms-90809-uiwebview-api-deprecation\/\">Matt Netkow<\/a> (via <a href=\"https:\/\/twitter.com\/elkmovie\/status\/1174753807756079104\">Michael Love<\/a>):<\/p>\n<blockquote cite=\"https:\/\/ionicframework.com\/blog\/understanding-itms-90809-uiwebview-api-deprecation\/\">\n<p>Recently, Apple introduced a new App Submission warning stating that they are formally deprecating <code>UIWebView<\/code>. We wanted to let the Ionic community know what this warning is all about and how the Ionic team plans to address it.<\/p>\n<p>[&#8230;]<\/p>\n<p>Sometime in the future, iOS apps may be blocked from release to the App Store when Apple decides to enforce blocking apps that use <code>UIWebView<\/code>.<\/p>\n<p>[&#8230;]<\/p>\n<p>The Cordova team is actively <a href=\"https:\/\/github.com\/apache\/cordova-discuss\/pull\/110\">discussing a plan<\/a> to move forward. This will take time as they plan the best way to move forward without severely impacting users.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/06\/20\/webview-and-uiwebview-deprecated-in-favor-of-wkwebview\/\">WebView and UIWebView Deprecated in Favor of WKWebView<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2017\/12\/22\/wkwebview-workarounds\/\">WKWebView Workarounds<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/01\/20\/wkwebview-sandboxing-and-searching\/\">WKWebView, Sandboxing, and Searching<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2014\/06\/06\/wkwebview\/\">WKWebView<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Brent Simmons: In NetNewsWire, I use JavaScript evaluation with a WKWebView to get the current scroll position. It broke in Catalina. I used document.body.scrollTop to get the y position, which appears to always return 0 now. Workaround: window.pageYOffset seems to work. Phil Dokas: The workaround I found was document.documentElement.scrollTop. This one&rsquo;s mutable where window.pageYOffset is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-10-21T19:54:41Z","apple_news_api_id":"67d2a9ff-7364-44f8-91b2-4e13ad3f5028","apple_news_api_modified_at":"2020-02-24T20:44:51Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AZ9Kp_3NkRPiRsk4TrT9QKA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[31,1667,346,30,1666,71,328,1926],"class_list":["post-26994","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-ios-13","tag-javascript","tag-mac","tag-macos-10-15","tag-programming","tag-webkit","tag-wkwebview"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=26994"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26994\/revisions"}],"predecessor-version":[{"id":26995,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26994\/revisions\/26995"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=26994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=26994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=26994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}