question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recalculate offsetX when browser resize

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior offset x still the same when resizing the window which makes horizontal scroll go over the void.

Expected behavior

recalculate the offset X on window resize

Reproduction of the problem

Go to this link https://swimlane.github.io/ngx-datatable/#horz-vert-scrolling now when you are in desktop mode… then resize your window… wait until you see the horizontal scroll… scroll it horizontally it will go over because the offset X is same as the old one… but if you refresh its fine but still on small window it will be fine… my problem is when switching to big and small… the value that scrollbar follows still thinks that offset X is same as the old one.

What is the motivation/use case for changing the behavior?

I dont know what the hell is this question xD Please tell us about your environment:

windows 10 visual studio code npm node

  • Table version:

latest

  • Angular version:

angular 8

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

all

  • Language: [all | TypeScript X.X | ES6/7 | ES5] TypeScript 3.6 es5 and 2015

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
adavis26commented, Sep 26, 2019

I found a work around for this! The only way to rebuild the DatatableComponent (as of now, recalculate will NOT work for me either) is to have an *ngIf on your ngx-datatable. You then need to have some sort of subscription to listen for when whatever data you are trying to load is actually loaded. So while data is not loading, your variable is false which hides the ngx datatable for the time being. Then once your data is all ready (columns and rows built for the table), then set this loading variable to true. Then, your table will be rebuilt. Ugh, yes quite the work around.

//global variable public isLoaded: Boolean = false;

<ngx-datatable *ngIf="isLoaded" [rows]="rows" [columns]="columns"></ngx-datatable>

Then, whenever your data does load in your data service, set the variable to true. If you are only returning local data, just set it to true when your rows and columns are done.

0reactions
hnfattahi76commented, Nov 16, 2022

I solved this issue. you can find the code below : .ngx-datatable .datatable-body-row > div { transform: translate3d(0, 0px, 0px) !important; }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recalculate Offset Value on window resize - Stack Overflow
The problem is that this function breaks on window resize and I am wondering if there is a simple way to recalculate the...
Read more >
MouseEvent offsetX Property - W3Schools
The offsetX property returns the x-coordinate of the mouse pointer, relative to the target element. Tip: To get the y-coordinate, use the offsetY...
Read more >
scale() - CSS: Cascading Style Sheets - MDN Web Docs
The scale() CSS function defines a transformation that resizes an element on the 2D plane. Because the amount of scaling is defined by...
Read more >
Recalculate jQuery function on window resize : r/jquery - Reddit
Have this jQuery function: jQuery(document).ready(function($) { if ($(window).width() > 927) { $(".nav-primary").headroom({ "offset": 250…
Read more >
Calculating size and position in a way that scales with text size
The objective of this technique is to calculate the size and position of elements in a way that will scale appropriately as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found