From 3cb21872549739a49faf3fb7b1bd44415521ebe5 Mon Sep 17 00:00:00 2001 From: luchenqun Date: Sun, 15 Apr 2018 23:10:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E7=AD=BE=E8=AF=A6=E6=83=85=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/scripts/controllers/note-controller.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/public/scripts/controllers/note-controller.js b/public/scripts/controllers/note-controller.js index 889fdca..c812bd0 100644 --- a/public/scripts/controllers/note-controller.js +++ b/public/scripts/controllers/note-controller.js @@ -215,6 +215,7 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind note.content = $scope.content; note.tagName = tagName; note.tag_id = $scope.currentTagId; + toPos(note.id); } }) $scope.add = false; @@ -270,10 +271,10 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind var detail = note.detail; $scope.notes.forEach((note) => { note.detail = false; - $("#" + note.id).removeClass("secondary") + $("#" + note.id).removeClass("secondary"); }) note.detail = !detail; - note.detail && $("#" + note.id).addClass("secondary") + note.detail && $("#" + note.id).addClass("secondary") && toPos(note.id); } if (flag) { $event && $event.stopPropagation(); @@ -387,4 +388,10 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind duration: 500, }); } + + function toPos(id) { + setTimeout(function(){ + $('html,body').animate({ scrollTop: $('#' + id).offset().top - 20 }, 100); + }, 36); + } }]);