From 78123b5db79058afa9b785031694db835fe6b4df Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 25 Aug 2016 14:30:42 +0800 Subject: [PATCH] =?UTF-8?q?iphone=E8=AE=BE=E5=A4=87=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=AE=9A=E4=BD=8D=E5=88=B0?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/directives/iphone_recognize.js | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/public/javascripts/wechat/directives/iphone_recognize.js b/public/javascripts/wechat/directives/iphone_recognize.js index fabba0e51..66014e71a 100644 --- a/public/javascripts/wechat/directives/iphone_recognize.js +++ b/public/javascripts/wechat/directives/iphone_recognize.js @@ -1,24 +1,28 @@ /** * Created by ttang on 2016/8/22. */ -app.directive('iphoneRecognize',function(){ +app.directive('iphoneRecognize',["$timeout",function(timer){ return{ restrict: 'A', scope: {}, link: function(scope, element){ - var userAgent = navigator.userAgent; + timer(function(){ + var userAgent = navigator.userAgent; + var contentHeight = $(".post-container").height(); if (/ipad|iphone|mac/i.test(navigator.userAgent)){ - $("#postInput1").bind('focus',function(){ - element.css({"position":"relative","padding":"1px 0"}); - $(".post-wrapper").css("margin-bottom","0"); - $("#all_homework_reply").css("margin-bottom","0"); - }); - $("#postInput1").bind('blur',function(){ - element.css("position","fixed"); - $(".post-wrapper").css("margin-bottom","10px"); - $("#all_homework_reply").css("margin-bottom","50px"); - }); + $("#postInput1").bind('focus',function(){ + element.css({"position":"relative","padding":"1px 0"}); + $(".post-wrapper").css("margin-bottom","0"); + $("#all_homework_reply").css("margin-bottom","0"); + window.scrollTo(0,contentHeight); + }); + $("#postInput1").bind('blur',function(){ + element.css("position","fixed"); + $(".post-wrapper").css("margin-bottom","10px"); + $("#all_homework_reply").css("margin-bottom","50px"); + }); } + }) } } -}); \ No newline at end of file +}]); \ No newline at end of file