Preventing div resizing in AngularJS through scroll functionality

I want to create dialog boxes that are draggable and resizable and can contain arbitrary HTML-formatted content. To achieve this, I am utilizing JQLite within a directive. The resizing functionality is triggered by a mousedown event on a div in the bottom corner (highlighted in blue in my Plunker here), allowing me to drag the mouse to resize the dialog box.

However, a problem arises when scrolling - the resize div moves up with the text instead of staying in the bottom corner. Other users on Stack Overflow faced a similar issue while using jQueryUI, but I am unsure how to address this within Angular. It seems like a simple HTML/CSS restructuring might solve the problem, but I am unsure about the exact steps to take. Any guidance on this matter would be greatly appreciated! The relevant code can be found below:

dialog.html: (code for the dialog box appearance)

<html>

<link href='dialog.css' rel='stylesheet' type='text/css'/>
<body>
    <div class='dialog' ng-style="{'width': model.width+'px', 'height': model.height+'px', 'top':model.top+'px', 'left':model.left+'px', 'z-index': model.zindex}" 
                        ng-mousedown='zorder()'>
        <span class='topbar'> 
            <button class='minimize' ng-click="minimize()"> _ </button>
        </span>
        <div class='content'>
          <ng-include src=model.template></ng-include>
        </div>
        <div class='drag'></div>     //the resize div
    </div>
</body>
</html>

dialog.css:

.dialog {
border: 1px black solid;
display: block;
position: absolute;
background-color: white;
overflow: auto;
 }

.topbar {
border: 1px lightgrey solid;
background-color: grey;
display: block;
}

.topbar:hover {
cursor: pointer;
}

.drag {
height:10px;
width: 10px;
display: block;
position: absolute;
bottom: 0;
right: 0;
background-color: blue;
}

.drag:hover {
cursor: nwse-resize;
}

.content {
overflow: scroll;
margin: 11px;
 }

Answer №1

Check out this solution:

.content {
position: absolute;
top: 26px; /** ensuring it is positioned under the minimize bar **/
right: 0;
bottom: 0; /** alternatively, set to 10px to place it above the resize area **/
left: 0;
overflow: auto;
margin: 11px;
}

By implementing this code, the content area will be scrollable while keeping the rest of the dialog box in a fixed position.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to use speech recognition on browsers besides Chrome?

Is there a way to utilize a microphone with JavaScript or HTML5 without relying on Flash technology? I was able to achieve this in Chrome by using webkit-speech, but I am looking for solutions that will work in other browsers as well. Any suggestions wou ...

django Ajax GET request could not locate the specified URL

I'm facing an issue while trying to pass parameters through Ajax with Django 1.11. The error message states: Not Found: /enquiry/followup_alter/. Below is the relevant code snippet. Error: Not Found: /enquiry/followup_alter/ Ajax: $(docume ...

Dividing the sentences inputted into a text area into an array and determining which sentence has been altered upon keyup

One of my current tasks involves handling the content within a textarea element: <textarea id="text"> Hello! Who am I? This is the third sentence. This, is another sentence. </textarea> Given that a textarea can be focused, I am seeking a met ...

AngularJS is patiently waiting for the tag to be loaded into the DOM

I am trying to incorporate a Google chart using an Angular directive on a webpage and I want to add an attribute to the element that is created after it has loaded. What is the most effective way to ensure that the element exists before adding the attribut ...

Troubleshooting a Border Problem in Bootstrap 5 Accordions

Having trouble with a Bootstrap 5 accordion header that has an icon drop-up menu. The bottom border disappears under the icon and I can't figure out why? HTML <div class="w-50 mt-5 mx-auto"> <div class="accordion favorites-f ...

What are the steps to personalize Twitter Bootstrap with Less for changing the height of the Navbar?

I recently stumbled upon some interesting articles that explain how to customize various elements of Twitter Bootstrap using LESS. You can check out one of the articles here and find more information about Twitter Bootstrap here. However, I am still unsure ...

HTML5 - Adding Space to Main Section with a Two-column Layout

After spending 3 and a half hours racking my brain, I still can't figure out how to complete two seemingly simple tasks. First, I need to pad the outside of paragraph div, and secondly, I want to split the main section into two columns to add some lin ...

Incorporating jQuery to seamlessly add elements without causing any disruptions to the layout

I'm looking to enhance the design of my website by adding a mouseenter function to display two lines when hovering over an item. However, I've encountered an issue where the appearance and disappearance of these lines cause the list items to move ...

Styling elements with CSS to achieve proper positioning

I am in search of a way to align rows utilizing the style property. The following HTML code is being transformed using XSL: <span style="white-space: pre; font-size: 8pt; font-family: Lucida console, Courier ">&lt;40 : item1</span>&l ...

What is a unique way to rename the 'yo' command in Yeoman to something of your choosing?

Is there a way to change the alias for creating a directive from $ yo directive myDirective To something like this: $ awesomeness directive myDirective If so, how can it be done? ...

Angular Material Popup - Interactive Map from AGM

I am in the process of developing a material dialog to collect user location information using AGM (angular google maps). I have successfully implemented a map on my main page, but when the dialog is opened, it only shows a blank space instead of the map. ...

Outlook's Dilemma with Background Images

I'm currently developing a new newsletter template, and I've encountered an issue with background images not displaying properly in Outlook. The code below illustrates the desired layout: <table style="width: 600px;" align="cent ...

Is there a way to prevent elements from resizing when zooming in or out?

What is the best way to prevent elements from resizing on a standard website when users zoom in (CTRL +)? ...

Error 404 occurred when attempting to use the DELETE method with Spring MVC and

Can anyone help me understand this issue? Everything is working fine, except for one method that isn't functioning and keeps giving a 404 error. I have a couple of requests function deleteFunc(id) { $.ajax({ dataType: "js ...

Ways to transfer data to a different PHP file without the need to navigate to the actual page

How can I make a button send information to another PHP folder while staying on the same page? <button class="btn btn-outline-dark w-60"><?php echo "<td> <a href='carrinho.php?acao=adc&id=$PegaID'>Adicionar ...

What causes offsetHeight to be less than clientHeight?

INFORMATION: clientHeight: Retrieves the height of an element, taking into account padding offsetHeight: Obtains the height of an element, considering padding, border, and scrollbar Analyzing the Data: The value returned by offsetHeight is expected to ...

Triggering the function once the text field is tapped again

I recently integrated a JavaScript scroll framework to create a stylish scrollbar for windows. I simply added it to a div: this.displayDiv = function () { $("#myDiv").niceScroll(); } <a href="#" onclick="manager.displayDiv();"> It ...

Please inquire about the steps to retrieve a user profile following a callback

My web application is incorporating Single Sign On (SSO) functionality from IBM Bluemix. Here is the authentication information for my SSO service: { "SingleSignOn": [ { "credentials": { "secret": "MYSECRET", "tokenEnd ...

Switching text and updating form action on button press using jquery

My current issue is that the button on my form is only partially working. Initially, it displays 'add' and directs to the 'add.php' file, but upon clicking the button, the text does not change and the submission doesn't go to the & ...

When accessing the website through an AJAX call and utilizing the Html.AntiForgeryToken() function, make sure the essential anti-forgery form field "__RequestVerificationToken" is included

My Controller has two action methods, both annotated with [ValidateAntiForgeryToken()]. The corresponding view includes @Html.AntiForgeryToken(). One of the methods (GetVendorOrders), which binds results to a Kendo grid, executes successfully. However, the ...