function insertReadStatusForUserAboutNote(noteId){
var TaskId = '@TM.Id';
var NoteId = noteId;
//run ajax
}
function check_if_in_view() {
var window_height = $(window).height();
var window_top_position = $(window).scrollTop();
var window_bottom_position = (window_top_position + window_height);
var elem = $('.scroll-to');
$.each(elem, function(e) {
var $element = $(this);
var dataId = $(this).attr('data-id');
var currentelement = '#sc_'+dataId;
var element_height = $element.outerHeight();
var element_top_position = $element.offset().top;
var element_bottom_position = (element_top_position + element_height);
//check to see if this current container is within viewport
if ((element_bottom_position >= window_top_position) &&
(element_top_position <= window_bottom_position)) {
$(currentelement).addClass('in-view');
insertReadStatusForUserAboutNote(dataId);
} else {
$(currentelement).removeClass('in-view');
}
});
}
$(window).scroll(function() {
var hT = $('.scroll-to').offset().top,
hH = $('.scroll-to').outerHeight(),
wH = $(window).height(),
wS = $(this).scrollTop();
console.log((hT-wH) , wS);
if($('#discussionForumSection').hasClass('show')){
if (wS > (hT+hH-wH)){
var j = $('.scroll-to').attr('data-id');
console.log( $('.scroll-to').attr('data-id'));
var t = $(this);
// alert('you have scrolled to the h1!');
check_if_in_view();
}
}
});
.in-view{
background-color :gray;
}
<p class="scroll-to" id="sc_@note.Id" data-Id="@note.Id">@Html.Raw(note.WorkNotes.Replace(Environment.NewLine, "<br />"))</p>
var TaskId = '@TM.Id';
var NoteId = noteId;
//run ajax
}
function check_if_in_view() {
var window_height = $(window).height();
var window_top_position = $(window).scrollTop();
var window_bottom_position = (window_top_position + window_height);
var elem = $('.scroll-to');
$.each(elem, function(e) {
var $element = $(this);
var dataId = $(this).attr('data-id');
var currentelement = '#sc_'+dataId;
var element_height = $element.outerHeight();
var element_top_position = $element.offset().top;
var element_bottom_position = (element_top_position + element_height);
//check to see if this current container is within viewport
if ((element_bottom_position >= window_top_position) &&
(element_top_position <= window_bottom_position)) {
$(currentelement).addClass('in-view');
insertReadStatusForUserAboutNote(dataId);
} else {
$(currentelement).removeClass('in-view');
}
});
}
$(window).scroll(function() {
var hT = $('.scroll-to').offset().top,
hH = $('.scroll-to').outerHeight(),
wH = $(window).height(),
wS = $(this).scrollTop();
console.log((hT-wH) , wS);
if($('#discussionForumSection').hasClass('show')){
if (wS > (hT+hH-wH)){
var j = $('.scroll-to').attr('data-id');
console.log( $('.scroll-to').attr('data-id'));
var t = $(this);
// alert('you have scrolled to the h1!');
check_if_in_view();
}
}
});
.in-view{
background-color :gray;
}
<p class="scroll-to" id="sc_@note.Id" data-Id="@note.Id">@Html.Raw(note.WorkNotes.Replace(Environment.NewLine, "<br />"))</p>

0 Comments