scroll

Jquery add CSS class after 'X' amount of viewport height scrolled

霸气de小男生 提交于 2020-02-04 03:35:46
问题 So I have this jQuery function that adds / removes a CSS class to an element after 600px of the viewport height has been scrolled. $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 600) { $(".cta_box").addClass('fadeout'); } else { $(".cta_box").removeClass('fadeout'); } }); I'd like to tweak it so instead of working based off a pixel value, it works off of the view height css measurement "VH", but the equivalent results are what matter in this case. 回答1: It can

Jquery add CSS class after 'X' amount of viewport height scrolled

落爺英雄遲暮 提交于 2020-02-04 03:35:04
问题 So I have this jQuery function that adds / removes a CSS class to an element after 600px of the viewport height has been scrolled. $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 600) { $(".cta_box").addClass('fadeout'); } else { $(".cta_box").removeClass('fadeout'); } }); I'd like to tweak it so instead of working based off a pixel value, it works off of the view height css measurement "VH", but the equivalent results are what matter in this case. 回答1: It can

Horizontal scroll with mouse wheel on horizontal list

倖福魔咒の 提交于 2020-02-03 05:05:05
问题 I'm attempting a horizontal scroll with the mouse wheel, but doesn't seem to work. Here is my Fiddle My main class .selector is the one with scrollable overflow This is JS I am trying to initialise the scroll with $('.selector').mousewheel(function(e, delta) { this.scrollLeft -= (delta * 40); e.preventDefault(); }); This is the example I am using for horizontal scroll https://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/ Thanks in advance for any help! EDIT: Thanks all, I

How to auto scroll top to bottom in react for messenger?

天涯浪子 提交于 2020-02-02 16:16:10
问题 How to auto scroll top to bottom in react for messenger or others? class MessageBox extends Component { componentDidMount() { this.scrollToBottom(); } componentDidUpdate() { this.scrollToBottom(); } scrollToBottom = () => { this.messagesEnd.scrollIntoView({ behavior: "smooth" }); } render() { return ( <div className="yourClass"> <div className="chat-textarea-box"> <MessageBox /> </div> <div ref={(el) => { this.messagesEnd = el; }}></div> </div> ) } } Please provide me better solutions 回答1: u

Attach scroll event to div with body on() binding fails

左心房为你撑大大i 提交于 2020-02-01 12:17:05
问题 I'm having some trouble with the scroll event. I'm trying to attach/bind the event to a specific div, and I'm using $('body').on() to do it, due to the fact that the content is reloaded when sorting, so it will lose its binding. This doesn't work, the event is not fired: $('body').on('scroll', 'div.dxgvHSDC + div', function () { } This on the other hand works: $('body').on('mousewheel DOMMouseScroll', 'div.dxgvHSDC + div', function () { } And this as well: $('div.dxgvHSDC + div').on('scroll',

Mobile Safari scroll momentum not working

给你一囗甜甜゛ 提交于 2020-01-31 05:16:24
问题 I'm having a bit of an issue with a responsive site at the moment. All but one of the pages don't get the scroll momentum you would normally get from using the Internet on your phone. I'm not sure if this is restricted to mobile safari or other mobile browsers, I've only just started the responsive work on this site. But, does anyone know why some pages might not have scroll momentum? Some of the pages are quite heavy with images and a little jQuery, but I wouldn't think there's enough to

How to use scrollStrategy in MatDialog?

℡╲_俬逩灬. 提交于 2020-01-31 03:22:49
问题 I tried to make a scroll for a dialog in reposition strategy, but it doesn't work for me. const scrollStrategy = this.overlay.scrollStrategies.reposition(); const dialogRef = this.dialog.open( DialogOverviewExampleDialog, { scrollStrategy } ); The full example I expect that during scrolling the whole dialog(element .cdk-overlay-pane ) will move Almost right behavior 回答1: If you want to scroll the content of the dialog then you have to use the <mat-dialog-content> tag, or use the directive mat

How to use scrollStrategy in MatDialog?

我的未来我决定 提交于 2020-01-31 03:22:27
问题 I tried to make a scroll for a dialog in reposition strategy, but it doesn't work for me. const scrollStrategy = this.overlay.scrollStrategies.reposition(); const dialogRef = this.dialog.open( DialogOverviewExampleDialog, { scrollStrategy } ); The full example I expect that during scrolling the whole dialog(element .cdk-overlay-pane ) will move Almost right behavior 回答1: If you want to scroll the content of the dialog then you have to use the <mat-dialog-content> tag, or use the directive mat

Invalidate is not redrawing the screen. Android

▼魔方 西西 提交于 2020-01-30 07:25:06
问题 BufferedReader hl = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.lines))); while(hl.ready()){ showLines.append(hl.readLine()+"\n"); showLines.invalidate(); Thread.sleep(10); } That is my code but it is not redrawing when I tell it to. It is supposed to redraw after every line that is added to textview, but it still only redraws at the end? Can someone please help me, I can't figure it out. 回答1: That is bacause your invalidate() is in a thread while loop and is

Cell with NSAttributedString makes the scrolling of UITableView slow

不打扰是莪最后的温柔 提交于 2020-01-30 07:00:26
问题 I have a table view that contains multiple kinds of cells. One of them is a cell with a TextView and in this text view, I have to render an NSAttributedString from data. This has to be done on the main Thread according to Apple documentation: The HTML importer should not be called from a background thread (that is, the options dictionary includes NSDocumentTypeDocumentAttribute with a value of NSHTMLTextDocumentType). It will try to synchronize with the main thread, fail, and time out.